[libcamera-devel,06/10] libcamera: ipa: raspberrypi: awb: Add SwitchMode method to output AWB status
diff mbox series

Message ID 20201116164918.2055-7-david.plowman@raspberrypi.com
State Superseded
Headers show
Series
  • Raspberry Pi AGC
Related show

Commit Message

David Plowman Nov. 16, 2020, 4:49 p.m. UTC
The Awb class now implements a SwitchMode method which outputs its
AwbStatus for other algorithms to read, should they be interested.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/ipa/raspberrypi/controller/rpi/awb.cpp | 14 ++++++++++++++
 src/ipa/raspberrypi/controller/rpi/awb.hpp |  1 +
 2 files changed, 15 insertions(+)

Comments

Naushir Patuck Nov. 17, 2020, 10:47 a.m. UTC | #1
Hi David,


On Mon, 16 Nov 2020 at 16:49, David Plowman <david.plowman@raspberrypi.com>
wrote:

> The Awb class now implements a SwitchMode method which outputs its
> AwbStatus for other algorithms to read, should they be interested.
>
> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
>

Reviewed-by: Naushir Patuck <naush@raspberrypi.com>


> ---
>  src/ipa/raspberrypi/controller/rpi/awb.cpp | 14 ++++++++++++++
>  src/ipa/raspberrypi/controller/rpi/awb.hpp |  1 +
>  2 files changed, 15 insertions(+)
>
> diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp
> b/src/ipa/raspberrypi/controller/rpi/awb.cpp
> index 469d0e53..020825e3 100644
> --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp
> +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp
> @@ -179,6 +179,20 @@ void Awb::SetManualGains(double manual_r, double
> manual_b)
>         manual_b_ = manual_b;
>  }
>
> +void Awb::SwitchMode([[maybe_unused]] CameraMode const &camera_mode,
> +                    Metadata *metadata)
> +{
> +       // If fixed colour gains have been set, we should let other
> algorithms
> +       // know by writing it into the image metadata.
> +       if (manual_r_ != 0.0 && manual_b_ != 0.0) {
> +               prev_sync_results_.gain_r = manual_r_;
> +               prev_sync_results_.gain_g = 1.0;
> +               prev_sync_results_.gain_b = manual_b_;
> +               sync_results_ = prev_sync_results_;
> +       }
> +       metadata->Set("awb.status", prev_sync_results_);
> +}
> +
>  void Awb::fetchAsyncResults()
>  {
>         RPI_LOG("Fetch AWB results");
> diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp
> b/src/ipa/raspberrypi/controller/rpi/awb.hpp
> index 9124d042..545d85a8 100644
> --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp
> +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp
> @@ -84,6 +84,7 @@ public:
>         void Read(boost::property_tree::ptree const &params) override;
>         void SetMode(std::string const &name) override;
>         void SetManualGains(double manual_r, double manual_b) override;
> +       void SwitchMode(CameraMode const &camera_mode, Metadata *metadata)
> override;
>         void Prepare(Metadata *image_metadata) override;
>         void Process(StatisticsPtr &stats, Metadata *image_metadata)
> override;
>         struct RGB {
> --
> 2.20.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>

Patch
diff mbox series

diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp
index 469d0e53..020825e3 100644
--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp
@@ -179,6 +179,20 @@  void Awb::SetManualGains(double manual_r, double manual_b)
 	manual_b_ = manual_b;
 }
 
+void Awb::SwitchMode([[maybe_unused]] CameraMode const &camera_mode,
+		     Metadata *metadata)
+{
+	// If fixed colour gains have been set, we should let other algorithms
+	// know by writing it into the image metadata.
+	if (manual_r_ != 0.0 && manual_b_ != 0.0) {
+		prev_sync_results_.gain_r = manual_r_;
+		prev_sync_results_.gain_g = 1.0;
+		prev_sync_results_.gain_b = manual_b_;
+		sync_results_ = prev_sync_results_;
+	}
+	metadata->Set("awb.status", prev_sync_results_);
+}
+
 void Awb::fetchAsyncResults()
 {
 	RPI_LOG("Fetch AWB results");
diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp
index 9124d042..545d85a8 100644
--- a/src/ipa/raspberrypi/controller/rpi/awb.hpp
+++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp
@@ -84,6 +84,7 @@  public:
 	void Read(boost::property_tree::ptree const &params) override;
 	void SetMode(std::string const &name) override;
 	void SetManualGains(double manual_r, double manual_b) override;
+	void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override;
 	void Prepare(Metadata *image_metadata) override;
 	void Process(StatisticsPtr &stats, Metadata *image_metadata) override;
 	struct RGB {