From patchwork Tue Dec 8 20:44:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10615 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 85F12BDB20 for ; Tue, 8 Dec 2020 20:44:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 41C1367E6F; Tue, 8 Dec 2020 21:44:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="hySDJF/3"; dkim-atps=neutral Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6D2BF67E4D for ; Tue, 8 Dec 2020 21:44:47 +0100 (CET) Received: by mail-ed1-x531.google.com with SMTP id i24so11129006edj.8 for ; Tue, 08 Dec 2020 12:44:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pvVockX49tEo+XYb/GBsyLuvcr9bEh20/7VlEgiMPRI=; b=hySDJF/3xxvInG0V0Gjgo0MM1BRwfYP8BU87H/IzIkwYzJ5E6/x+/nsiClgVTyED7Z 1M4k2Pnz+ymdzt1kUTJ60ItJxfsbuzVYz6I930TYyhW4U5Q0hyvnm2BUw9fJfbr7gBdI ztaOLaqycjY9asqeBUqitnj80TbW1KEBNMOzwQoyzgtqnXCABhYl4vliUvpb0uRBg27g nhQRYT5K5a+VZewEG7yqUzhgAV4cXYDMqtqAcadKlTyInfHHJCpfpyS4u3wrm5Ul0zF2 ZihVO/DR/opJFtUokwgTrpvn8szjiZZ7QCJXV8COMcbVraDvLv9YlXZoW21232HSSZLU G7aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pvVockX49tEo+XYb/GBsyLuvcr9bEh20/7VlEgiMPRI=; b=PdbZPm9suXA45IJCUS1/b6A4nDwyPN6NXr6KlLksGPJ+a9rqus8Ty5XDJL9q+yu4GT FLzXpniJlNoEEF/io/ebbsR0KMNAnMjbil142/2TlkqL+eCWxH92ogeWx31rAJ8dFDS1 WXJZBsEFC69RRWNLHHsbJgQgSvs0+Fhz/e7SCa1rGnEE2Y/grkZyge2dWHYScq2WVAk5 qtidWPQmmklV7t03yg3fIGTOHkjmSD5fRCTWGtdv2s8k7fJX/cXBCKzomUlzIxDrAHTv xVCnjENIKKJV3Tq920EGQ7S/6DZma94DlLaCcpZapXupBvkb0N4GIavAFD4BAT7FC036 rWqQ== X-Gm-Message-State: AOAM5305/O7tNoVGQQLMTKempUpdnRO1CQ+kk12wpx1Ur85H8egZ9BBB 0kZC84Hxb9yW1qSHHd3Cp/RvNk2OUMVUeNWj X-Google-Smtp-Source: ABdhPJz5RRjZujl3SuxuJAMeZoJblkc7uEYC/6+3YYBA6v/4CO8SJ7e+F/iHMt/cbPHYQT1u5C/7zg== X-Received: by 2002:a50:ab47:: with SMTP id t7mr26771256edc.289.1607460286723; Tue, 08 Dec 2020 12:44:46 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id be6sm18441471edb.29.2020.12.08.12.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 12:44:46 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Dec 2020 20:44:38 +0000 Message-Id: <20201208204441.9356-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201208204441.9356-1-david.plowman@raspberrypi.com> References: <20201208204441.9356-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/6] src: ipa: raspberrypi: awb: Add GetConvergenceFrames method to AWB base class X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We add a GetConvergenceFrames method to the AwbAlgorithm class which can be called when the AWB is started from scratch. It suggests how many frames should be dropped before displaying any (while the AWB converges). The Raspberry Pi specific implementation makes this customisable from the tuning file. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/awb_algorithm.hpp | 1 + src/ipa/raspberrypi/controller/rpi/awb.cpp | 11 +++++++++++ src/ipa/raspberrypi/controller/rpi/awb.hpp | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/ipa/raspberrypi/controller/awb_algorithm.hpp b/src/ipa/raspberrypi/controller/awb_algorithm.hpp index 5be0c9f4..96f88afc 100644 --- a/src/ipa/raspberrypi/controller/awb_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/awb_algorithm.hpp @@ -15,6 +15,7 @@ class AwbAlgorithm : public Algorithm public: AwbAlgorithm(Controller *controller) : Algorithm(controller) {} // An AWB algorithm must provide the following: + virtual unsigned int GetConvergenceFrames() const = 0; virtual void SetMode(std::string const &mode_name) = 0; virtual void SetManualGains(double manual_r, double manual_b) = 0; }; diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index 020825e3..10600f75 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -59,6 +59,7 @@ void AwbConfig::Read(boost::property_tree::ptree const ¶ms) bayes = params.get("bayes", 1); frame_period = params.get("frame_period", 10); startup_frames = params.get("startup_frames", 10); + convergence_frames = params.get("convergence_frames", 3); speed = params.get("speed", 0.05); if (params.get_child_optional("ct_curve")) read_ct_curve(ct_r, ct_b, params.get_child("ct_curve")); @@ -165,6 +166,16 @@ void Awb::Initialise() prev_sync_results_ = sync_results_; } +unsigned int Awb::GetConvergenceFrames() const +{ + // If colour gains have been explicitly set, there is no convergence + // to happen, so no need to drop any frames - return zero. + if (manual_r_ && manual_b_) + return 0; + else + return config_.convergence_frames; +} + void Awb::SetMode(std::string const &mode_name) { std::unique_lock lock(settings_mutex_); diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp index 545d85a8..6fc045ce 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp @@ -37,6 +37,7 @@ struct AwbConfig { uint16_t frame_period; // number of initial frames for which speed taken as 1.0 (maximum) uint16_t startup_frames; + unsigned int convergence_frames; // approx number of frames to converge double speed; // IIR filter speed applied to algorithm results bool fast; // "fast" mode uses a 16x16 rather than 32x32 grid Pwl ct_r; // function maps CT to r (= R/G) @@ -82,6 +83,7 @@ public: char const *Name() const override; void Initialise() override; void Read(boost::property_tree::ptree const ¶ms) override; + unsigned int GetConvergenceFrames() const 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;