[libcamera-devel] [PATCH 2/3] libcamera: raspberrypi: Add ColourCorrectionMatrix control
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Jul 24 02:38:46 CEST 2020
Hi David,
Thank you for the patch.
On Sat, Jul 04, 2020 at 10:59:13AM +0100, David Plowman wrote:
> Implements, for the Raspberry Pi platform, the returning of the CCM
> (Colour Correction Matrix) used by the pipeline in the libcamera
> metadata.
>
> Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
> ---
> include/libcamera/ipa/raspberrypi.h | 1 +
> src/ipa/raspberrypi/raspberrypi.cpp | 9 +++++++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
> index a18ce9a..2682319 100644
> --- a/include/libcamera/ipa/raspberrypi.h
> +++ b/include/libcamera/ipa/raspberrypi.h
> @@ -52,6 +52,7 @@ static const ControlInfoMap RPiControls = {
> { &controls::Contrast, ControlInfo(0.0f, 32.0f) },
> { &controls::Saturation, ControlInfo(0.0f, 32.0f) },
> { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },
> + { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },
> };
>
> } /* namespace libcamera */
> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
> index bc89ab5..592bb04 100644
> --- a/src/ipa/raspberrypi/raspberrypi.cpp
> +++ b/src/ipa/raspberrypi/raspberrypi.cpp
> @@ -404,6 +404,15 @@ void IPARPi::reportMetadata()
> static_cast<int32_t>(blackLevelStatus->black_level_g),
> static_cast<int32_t>(blackLevelStatus->black_level_g),
> static_cast<int32_t>(blackLevelStatus->black_level_b) });
> +
> + CcmStatus *ccmStatus = rpiMetadata_.GetLocked<CcmStatus>("ccm.status");
> + if (ccmStatus) {
> + float m[9];
> + int i;
> + for (i = 0; i < 9; i++)
for (unsigned int i = 0; i < 9; i++)
> + m[i] = ccmStatus->matrix[i];
or now that I think about it, may
for (double v : ccmStatus->matrix)
m[i++] = v;
or
std::transform(std::begin(ccmStatus->matrix),
std::end(ccmStatus->matrix), std::begin(m),
[](double v) { return static_cast<float>(v); });
if you think any of those two would be better.
Which option do you like best ?
> + libcameraMetadata_.set(controls::ColourCorrectionMatrix, m);
> + }
> }
>
> /*
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list