mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-14 07:59:44 +03:00
ipa: rkisp1: Add manual color gains
Add support for manually controlling the color gains on the rkisp1 IPA. To that end, add and plumb the AwbEnable and ColourGains controls. As per-frame controls aren't supported yet in the rkisp1 IPA, simply apply and perform checks on the controls immediately. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
bf3dbaece9
commit
3200bb635c
5 changed files with 42 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <libcamera/base/log.h>
|
#include <libcamera/base/log.h>
|
||||||
|
|
||||||
|
#include <libcamera/control_ids.h>
|
||||||
#include <libcamera/ipa/core_ipa_interface.h>
|
#include <libcamera/ipa/core_ipa_interface.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,6 +39,7 @@ int Awb::configure(IPAContext &context,
|
||||||
context.frameContext.awb.gains.red = 1.0;
|
context.frameContext.awb.gains.red = 1.0;
|
||||||
context.frameContext.awb.gains.blue = 1.0;
|
context.frameContext.awb.gains.blue = 1.0;
|
||||||
context.frameContext.awb.gains.green = 1.0;
|
context.frameContext.awb.gains.green = 1.0;
|
||||||
|
context.frameContext.awb.autoEnabled = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the measurement window for AWB as a centered rectangle
|
* Define the measurement window for AWB as a centered rectangle
|
||||||
|
@ -116,6 +118,34 @@ void Awb::prepare(IPAContext &context, rkisp1_params_cfg *params)
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_AWB;
|
params->module_ens |= RKISP1_CIF_ISP_MODULE_AWB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \copydoc libcamera::ipa::Algorithm::queueRequest
|
||||||
|
*/
|
||||||
|
void Awb::queueRequest(IPAContext &context,
|
||||||
|
[[maybe_unused]] const uint32_t frame,
|
||||||
|
const ControlList &controls)
|
||||||
|
{
|
||||||
|
auto &awb = context.frameContext.awb;
|
||||||
|
|
||||||
|
const auto &awbEnable = controls.get(controls::AwbEnable);
|
||||||
|
if (awbEnable && *awbEnable != awb.autoEnabled) {
|
||||||
|
awb.autoEnabled = *awbEnable;
|
||||||
|
|
||||||
|
LOG(RkISP1Awb, Debug)
|
||||||
|
<< (*awbEnable ? "Enabling" : "Disabling") << " AWB";
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &colourGains = controls.get(controls::ColourGains);
|
||||||
|
if (colourGains && !awb.autoEnabled) {
|
||||||
|
awb.gains.red = (*colourGains)[0];
|
||||||
|
awb.gains.blue = (*colourGains)[1];
|
||||||
|
|
||||||
|
LOG(RkISP1Awb, Debug)
|
||||||
|
<< "Set colour gains to red: " << awb.gains.red
|
||||||
|
<< ", blue: " << awb.gains.blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \copydoc libcamera::ipa::Algorithm::process
|
* \copydoc libcamera::ipa::Algorithm::process
|
||||||
*/
|
*/
|
||||||
|
@ -164,8 +194,10 @@ void Awb::process([[maybe_unused]] IPAContext &context,
|
||||||
* Gain values are unsigned integer value, range 0 to 4 with 8 bit
|
* Gain values are unsigned integer value, range 0 to 4 with 8 bit
|
||||||
* fractional part.
|
* fractional part.
|
||||||
*/
|
*/
|
||||||
|
if (frameContext.awb.autoEnabled) {
|
||||||
frameContext.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);
|
frameContext.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);
|
||||||
frameContext.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);
|
frameContext.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);
|
||||||
|
}
|
||||||
/* Hardcode the green gain to 1.0. */
|
/* Hardcode the green gain to 1.0. */
|
||||||
frameContext.awb.gains.green = 1.0;
|
frameContext.awb.gains.green = 1.0;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ public:
|
||||||
|
|
||||||
int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;
|
int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;
|
||||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||||
|
void queueRequest(IPAContext &context, const uint32_t frame,
|
||||||
|
const ControlList &controls) override;
|
||||||
void process(IPAContext &context, IPAFrameContext *frameCtx,
|
void process(IPAContext &context, IPAFrameContext *frameCtx,
|
||||||
const rkisp1_stat_buffer *stats) override;
|
const rkisp1_stat_buffer *stats) override;
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,9 @@ namespace libcamera::ipa::rkisp1 {
|
||||||
*
|
*
|
||||||
* \var IPAFrameContext::awb.temperatureK
|
* \var IPAFrameContext::awb.temperatureK
|
||||||
* \brief Estimated color temperature
|
* \brief Estimated color temperature
|
||||||
|
*
|
||||||
|
* \var IPAFrameContext::awb.autoEnabled
|
||||||
|
* \brief Whether the Auto White Balance algorithm is enabled
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,6 +55,7 @@ struct IPAFrameContext {
|
||||||
} gains;
|
} gains;
|
||||||
|
|
||||||
double temperatureK;
|
double temperatureK;
|
||||||
|
bool autoEnabled;
|
||||||
} awb;
|
} awb;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -92,6 +92,8 @@ namespace {
|
||||||
/* List of controls handled by the RkISP1 IPA */
|
/* List of controls handled by the RkISP1 IPA */
|
||||||
const ControlInfoMap::Map rkisp1Controls{
|
const ControlInfoMap::Map rkisp1Controls{
|
||||||
{ &controls::AeEnable, ControlInfo(false, true) },
|
{ &controls::AeEnable, ControlInfo(false, true) },
|
||||||
|
{ &controls::AwbEnable, ControlInfo(false, true) },
|
||||||
|
{ &controls::ColourGains, ControlInfo(0.0f, 3.996f, 1.0f) },
|
||||||
{ &controls::Brightness, ControlInfo(-1.0f, 0.993f) },
|
{ &controls::Brightness, ControlInfo(-1.0f, 0.993f) },
|
||||||
{ &controls::Contrast, ControlInfo(0.0f, 1.993f) },
|
{ &controls::Contrast, ControlInfo(0.0f, 1.993f) },
|
||||||
{ &controls::Saturation, ControlInfo(0.0f, 1.993f) },
|
{ &controls::Saturation, ControlInfo(0.0f, 1.993f) },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue