Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of API/user config controlled auto exposure and gain settings #43

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ESP/ini/dev_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ build_flags =
-DADHOC_CHANNEL=${wifi.adhocchannel}
-DWIFI_CHANNEL=${wifi.channel}
-DDEBUG_ESP_PORT=Serial
'-DVERSION=""' ; set the debug port
'-DMDNS_HOSTNAME=${wifi.mdnsname}' ; Set the OTA password
'-DVERSION=""'
'-DMDNS_HOSTNAME=${wifi.mdnsname}'
-DSIMPLE_AUTO_EXPOSURE_ON=${autoexposure.simple_auto_exposure_on}
-DFANCY_AUTO_EXPOSURE_ON=${autoexposure.fancy_auto_exposure_on}
-DAE_LEVEL=${autoexposure.ae_level}
-DAEC_VALUE=${autoexposure.aec_value}
-DAUTO_GAIN_ON=${autoexposure.auto_gain_on}
-DBRIGHTNESS=${autoexposure.brightness}
'-DWIFI_SSID=${wifi.ssid}'
'-DWIFI_PASSWORD=${wifi.password}'
'-DWIFI_AP_SSID=${wifi.ap_ssid}'
Expand Down
11 changes: 11 additions & 0 deletions ESP/ini/user_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ otaserverip = "openiristracker.local"
otalogin = "openiris"
otapassword = "12345678"
otaserverport = 3232

[autoexposure]
simple_auto_exposure_on = 0 ; should the auto exposure be enabled, 0 - off, 1 - on
fancy_auto_exposure_on = 0 ; should the more advanced auto exposure be enabled, 0 - on, 1 - off

ae_level = 0 ; auto exposure level, -2 to 2, 0 is the default
aec_value = 300 ; auto exposure control, a sort of brightness, 0 - 1200

auto_gain_on = 0 ; should the auto gain be enabled, 0 - off, 1 - on

brightness = 2 ; controls the brightness, -2 to 2, to is the default
35 changes: 31 additions & 4 deletions ESP/lib/src/data/config/project_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ void ProjectConfig::initConfig() {
.href = 0,
.framesize = 4,
.quality = 7,
.brightness = 2,
.brightness = BRIGHTNESS,
.simple_auto_exposure_on = SIMPLE_AUTO_EXPOSURE_ON,
.fancy_auto_exposure_on = FANCY_AUTO_EXPOSURE_ON,
.ae_level = AE_LEVEL,
.aec_value = AEC_VALUE,
.auto_gain_on = AUTO_GAIN_ON,
};
}

Expand Down Expand Up @@ -132,6 +137,12 @@ void ProjectConfig::cameraConfigSave() {
putInt("framesize", this->config.camera.framesize);
putInt("quality", this->config.camera.quality);
putInt("brightness", this->config.camera.brightness);
putInt("brightness", this->config.camera.brightness);
putInt("simple_auto_exposure_on", this->config.camera.fancy_auto_exposure_on);
putInt("fancy_auto_exposure_on", this->config.camera.fancy_auto_exposure_on);
putInt("ae_level", this->config.camera.ae_level);
putInt("aec_value", this->config.camera.aec_value);
putInt("auto_gain_on ", this->config.camera.auto_gain_on);
}

bool ProjectConfig::reset() {
Expand Down Expand Up @@ -198,7 +209,12 @@ void ProjectConfig::load() {
this->config.camera.href = getInt("href", 0);
this->config.camera.framesize = getInt("framesize", 4);
this->config.camera.quality = getInt("quality", 7);
this->config.camera.brightness = getInt("brightness", 2);
this->config.camera.brightness = getInt("brightness", BRIGHTNESS);
this->config.camera.fancy_auto_exposure_on = getInt("simple_auto_exposure_on", SIMPLE_AUTO_EXPOSURE_ON);
this->config.camera.fancy_auto_exposure_on = getInt("fancy_auto_exposure_on", FANCY_AUTO_EXPOSURE_ON);
this->config.camera.ae_level = getInt("ae_level", AE_LEVEL);
this->config.camera.aec_value = getInt("aec_value", AEC_VALUE);
this->config.camera.auto_gain_on = getInt("auto_gain_on ", AUTO_GAIN_ON);

this->_already_loaded = true;
this->notifyAll(ConfigState_e::configLoaded);
Expand Down Expand Up @@ -238,13 +254,23 @@ void ProjectConfig::setCameraConfig(uint8_t vflip,
uint8_t href,
uint8_t quality,
uint8_t brightness,
bool simple_auto_exposure_on,
bool fancy_auto_exposure_on,
int ae_level,
unsigned int aec_value,
bool auto_gain_on,
bool shouldNotify) {
log_d("Updating camera config");
this->config.camera.vflip = vflip;
this->config.camera.href = href;
this->config.camera.framesize = framesize;
this->config.camera.quality = quality;
this->config.camera.brightness = brightness;
this->config.camera.simple_auto_exposure_on = simple_auto_exposure_on;
this->config.camera.fancy_auto_exposure_on = fancy_auto_exposure_on;
this->config.camera.ae_level = ae_level;
this->config.camera.aec_value = aec_value;
this->config.camera.auto_gain_on = auto_gain_on;

log_d("Updating Camera config");
if (shouldNotify)
Expand Down Expand Up @@ -384,9 +410,10 @@ std::string ProjectConfig::MDNSConfig_t::toRepresentation() {
std::string ProjectConfig::CameraConfig_t::toRepresentation() {
std::string json = Helpers::format_string(
"\"camera_config\": {\"vflip\": %d,\"framesize\": %d,\"href\": "
"%d,\"quality\": %d,\"brightness\": %d}",
"%d,\"quality\": %d,\"brightness\": %d, \"simple_auto_exposure_on\": %d, \"fancy_auto_exposure_on\": %d,\"ae_level\": %d, \"aec_value\": %d, \"auto_gain_on\": %d }",
this->vflip, this->framesize, this->href, this->quality,
this->brightness);
this->brightness, this->simple_auto_exposure_on, this->fancy_auto_exposure_on,
this->aec_value, this->ae_level, this->auto_gain_on);
return json;
}

Expand Down
14 changes: 12 additions & 2 deletions ESP/lib/src/data/config/project_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ class ProjectConfig : public Preferences, public ISubject<ConfigState_e> {
struct CameraConfig_t {
uint8_t vflip;
uint8_t href;
uint8_t framesize;
int framesize;
uint8_t quality;
uint8_t brightness;
int brightness;
bool simple_auto_exposure_on;
bool fancy_auto_exposure_on;
int ae_level;
int aec_value;
bool auto_gain_on;

std::string toRepresentation();
};
Expand Down Expand Up @@ -116,6 +121,11 @@ class ProjectConfig : public Preferences, public ISubject<ConfigState_e> {
uint8_t href,
uint8_t quality,
uint8_t brightness,
bool simple_auto_exposure_on,
bool fancy_auto_exposure_on,
int ae_level,
unsigned int aec_value,
bool auto_gain_on,
bool shouldNotify);
void setWifiConfig(const std::string& networkName,
const std::string& ssid,
Expand Down
Loading