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

Rename and move "mean threshold" #2789

Merged
merged 3 commits into from
Jun 14, 2023
Merged
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
1 change: 0 additions & 1 deletion src/capture_RPi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ int main(int argc, char *argv[])
// TODO: after merging myModeMeanSetting into CG.myModeMeanSetting, delete these lines.
myModeMeanSetting.dayMean = CG.myModeMeanSetting.dayMean;
myModeMeanSetting.nightMean = CG.myModeMeanSetting.nightMean;
myModeMeanSetting.mean_threshold = CG.myModeMeanSetting.mean_threshold; // xxxxxx TODO: old name
myModeMeanSetting.dayMean_threshold = CG.myModeMeanSetting.dayMean_threshold;
myModeMeanSetting.nightMean_threshold = CG.myModeMeanSetting.nightMean_threshold;
myModeMeanSetting.mean_p0 = CG.myModeMeanSetting.mean_p0;
Expand Down
1 change: 0 additions & 1 deletion src/include/mode_mean.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ struct modeMeanSetting {
// Default threshold values for daytime and nighttime. User can change.
double dayMean_threshold = DEFAULT_DAYMEAN_THRESHOLD_RPi;
double nightMean_threshold = DEFAULT_NIGHTMEAN_THRESHOLD_RPi;
double mean_threshold = DEFAULT_DAYMEAN_THRESHOLD_RPi; // TODO: xxx will remove in next version

double const shuttersteps = 6.0; // shuttersteps
int const historySize = 3; // Number of last images for mean target calculation.
Expand Down
24 changes: 12 additions & 12 deletions src/mode_mean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,24 +243,24 @@ void aegGetNextExposureSettings(config * cg,
double meanDiff = abs(cg->lastMean - cg->myModeMeanSetting.currentMean); // xxx was = mean_diff

// fast forward
if (fastforward || meanDiff > (currentModeMeanSetting.mean_threshold * multiplier1)) {
if (fastforward || meanDiff > (cg->myModeMeanSetting.currentMean_threshold * multiplier1)) {
// We are fairly far off from desired mean so make a big change next time.
ExposureChange = std::max(1.0, currentModeMeanSetting.mean_p0 + (currentModeMeanSetting.mean_p1 * mean_diff) + pow(currentModeMeanSetting.mean_p2 * mean_diff, 2.0));
Log(3, " > fast forward ExposureChange now %d (meanDiff=%1.3f > %.2f*threshold=%1.3f)\n",
ExposureChange, meanDiff, multiplier1, currentModeMeanSetting.mean_threshold*multiplier1);
ExposureChange, meanDiff, multiplier1, cg->myModeMeanSetting.currentMean_threshold*multiplier1);
}
else if (meanDiff > (currentModeMeanSetting.mean_threshold * multiplier2)) {
else if (meanDiff > (cg->myModeMeanSetting.currentMean_threshold * multiplier2)) {
// We are somewhat far off from desired mean so make a big change next time.
ExposureChange = std::max(1.0, currentModeMeanSetting.mean_p0 + (currentModeMeanSetting.mean_p1 * mean_diff) + (pow(currentModeMeanSetting.mean_p2 * mean_diff, 2.0) / 2.0));
Log(3, " > medium forward ExposureChange now %d (meanDiff=%1.3f > %.2f*threshold=%1.3f)\n",
ExposureChange, meanDiff, multiplier2, currentModeMeanSetting.mean_threshold*multiplier2);
ExposureChange, meanDiff, multiplier2, cg->myModeMeanSetting.currentMean_threshold*multiplier2);
}
// slow forward
else if (meanDiff > currentModeMeanSetting.mean_threshold) {
else if (meanDiff > cg->myModeMeanSetting.currentMean_threshold) {
// We are fairly close to desired mean so make a small change next time.
ExposureChange = std::max(1.0, currentModeMeanSetting.mean_p0 + currentModeMeanSetting.mean_p1 * mean_diff);
Log(3, " > slow forward ExposureChange now %d (meanDiff=%1.3f, %.2f*threshold=%1.3f)\n",
ExposureChange, meanDiff, multiplier2, currentModeMeanSetting.mean_threshold*multiplier2);
ExposureChange, meanDiff, multiplier2, cg->myModeMeanSetting.currentMean_threshold*multiplier2);
}
else {
// We are within the threshold
Expand All @@ -275,9 +275,9 @@ void aegGetNextExposureSettings(config * cg,
Log(4, " > ExposureChange clipped to %d (diff from last change: %d)\n", ExposureChange, dExposureChange);

// If the last image's mean was good, no changes are needed to the next one.
// TODO: make mean_threshold a percent instead of an actual value. This will allow us to use 0 to 100 for what user enters as mean.
// TODO: make currentMean_threshold a percent instead of an actual value. This will allow us to use 0 to 100 for what user enters as mean.

if (cg->lastMean < (cg->myModeMeanSetting.currentMean - currentModeMeanSetting.mean_threshold)) {
if (cg->lastMean < (cg->myModeMeanSetting.currentMean - cg->myModeMeanSetting.currentMean_threshold)) {
// mean too low
if ((currentRaspistillSetting.analoggain < currentModeMeanSetting.maxGain)
|| (currentRaspistillSetting.shutter_us < currentModeMeanSetting.maxExposure_us)) {
Expand All @@ -291,7 +291,7 @@ void aegGetNextExposureSettings(config * cg,
currentModeMeanSetting.maxGain, length_in_units(currentModeMeanSetting.maxExposure_us, true));
}
}
else if (cg->lastMean > (cg->myModeMeanSetting.currentMean + currentModeMeanSetting.mean_threshold)) {
else if (cg->lastMean > (cg->myModeMeanSetting.currentMean + cg->myModeMeanSetting.currentMean_threshold)) {
// mean too high
if ((currentRaspistillSetting.analoggain > currentModeMeanSetting.minGain)
|| (lastExposureTime_us > currentModeMeanSetting.minExposure_us)) {
Expand All @@ -307,7 +307,7 @@ void aegGetNextExposureSettings(config * cg,
}
else {
Log(3, " > ++++++++++ Prior image mean good - no changes needed, mean=%1.3f, target mean=%1.3f threshold=%1.3f\n",
cg->lastMean, cg->myModeMeanSetting.currentMean, currentModeMeanSetting.mean_threshold);
cg->lastMean, cg->myModeMeanSetting.currentMean, cg->myModeMeanSetting.currentMean_threshold);
cg->goodLastExposure = true;
}

Expand All @@ -323,8 +323,8 @@ void aegGetNextExposureSettings(config * cg,
Log(4, " > FF activated\n");
}
if (fastforward &&
(abs(meanHistory[idx] - cg->myModeMeanSetting.currentMean) < currentModeMeanSetting.mean_threshold) &&
(abs(meanHistory[idxN1] - cg->myModeMeanSetting.currentMean) < currentModeMeanSetting.mean_threshold)) {
(abs(meanHistory[idx] - cg->myModeMeanSetting.currentMean) < cg->myModeMeanSetting.currentMean_threshold) &&
(abs(meanHistory[idxN1] - cg->myModeMeanSetting.currentMean) < cg->myModeMeanSetting.currentMean_threshold)) {
fastforward = false;
Log(4, " > FF deactivated\n");
}
Expand Down