libcamera: software_isp: Add manual exposure control
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
8ad3af24e8
commit
9305cb267b
2 changed files with 14 additions and 2 deletions
|
@ -46,6 +46,8 @@ int Agc::init(IPAContext &context,
|
|||
{
|
||||
context.ctrlMap[&controls::AeEnable] = ControlInfo(false, true, true);
|
||||
context.ctrlMap[&controls::Brightness] = ControlInfo(0.0f, 2.0f, 1.0f);
|
||||
context.ctrlMap[&controls::ExposureValue] = ControlInfo(0.0f, 0.5f, 1.0f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -65,6 +67,7 @@ void Agc::queueRequest(typename Module::Context &context,
|
|||
{
|
||||
const auto &brightness = controls.get(controls::Brightness);
|
||||
const auto &ae_enabled = controls.get(controls::AeEnable);
|
||||
const auto &exposure_value = controls.get(controls::ExposureValue);
|
||||
if (brightness.has_value()) {
|
||||
context.activeState.knobs.brightness = brightness;
|
||||
LOG(IPASoftExposure, Debug) << "Setting brightness to " << brightness.value();
|
||||
|
@ -73,6 +76,10 @@ void Agc::queueRequest(typename Module::Context &context,
|
|||
context.activeState.knobs.ae_enabled = ae_enabled;
|
||||
LOG(IPASoftExposure, Debug) << "Setting ae_enable to " << ae_enabled.value();
|
||||
}
|
||||
if (exposure_value.has_value()) {
|
||||
context.activeState.knobs.exposure_value = exposure_value.value();
|
||||
LOG(IPASoftExposure, Debug) << "Setting exposure value to " << exposure_value.value();
|
||||
}
|
||||
}
|
||||
|
||||
void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV)
|
||||
|
@ -140,13 +147,16 @@ void Agc::process(IPAContext &context,
|
|||
ControlList &metadata)
|
||||
{
|
||||
const auto ae_enable = context.activeState.knobs.ae_enabled.value_or(true);
|
||||
if (!ae_enable)
|
||||
return;
|
||||
|
||||
if (!ae_enable)
|
||||
frameContext.sensor.exposure = (int32_t)( context.activeState.knobs.exposure_value.value_or(0.5) * (context.configuration.agc.exposureMax - context.configuration.agc.exposureMin));
|
||||
utils::Duration exposureTime =
|
||||
context.configuration.agc.lineDuration * frameContext.sensor.exposure;
|
||||
metadata.set(controls::ExposureTime, exposureTime.get<std::micro>());
|
||||
metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
|
||||
LOG(IPASoftExposure, Debug) << "Setting exposure value to " << frameContext.sensor.exposure;
|
||||
if (!ae_enable)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Calculate Mean Sample Value (MSV) according to formula from:
|
||||
|
|
|
@ -71,6 +71,8 @@ struct IPAActiveState {
|
|||
std::optional<double> brightness;
|
||||
/* 0..1 range, 1 = normal */
|
||||
std::optional<bool> ae_enabled;
|
||||
/* 0..1 range, 0.5 = normal */
|
||||
std::optional<double> exposure_value;
|
||||
/* 0..100 range, 50.0 = normal */
|
||||
std::optional<double> focus_pos;
|
||||
} knobs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue