From patchwork Mon Dec 7 18:01:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10600 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 6F3D9BDB1F for ; Mon, 7 Dec 2020 18:02:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 35F1967E6E; Mon, 7 Dec 2020 19:02:15 +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="QKKkQbLB"; dkim-atps=neutral Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A74C67E6A for ; Mon, 7 Dec 2020 19:02:14 +0100 (CET) Received: by mail-ed1-x533.google.com with SMTP id dk8so11818694edb.1 for ; Mon, 07 Dec 2020 10:02:14 -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=mknaU4XTrtLYRHZO3lNKtJ3aTj6z6MQXh7SDuOwDMTg=; b=QKKkQbLB4qmjWSRMMi8lNGn1YJRaxfbdMIWRiXR57fn0+o5nhV5c9sBip/rKXlinuI RwiuJCFO3w1N2qaIzhXjwsYaaSpeQPbxJNQxj3/DBRKQSmiX6GKeAmtuKSm/6i64zwwg knkdEBBRq+jeQ8jJ2OnidaS+NtGsa7sIaj37K36SRJTtbuALM7ZierEwGAAh9RKLYxdb R6llxXbKWLfrAuddcp6TrQtwMC5kkt7eEFX0rsV2W4FqKz+N/hD2cn6hTCQWRFkd/+Bx IhyhyeLXsoVJrJh9v6wHN6FDxbj+IsVt5SrFUYjPHQ8ufUyDvIVkB1sXn5BU+Bd+2tJV QyUA== 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=mknaU4XTrtLYRHZO3lNKtJ3aTj6z6MQXh7SDuOwDMTg=; b=bwNfwFixjRhD25yvbdwnTX91FjDIdmFO8POiS4+s1xNQj3KamhId7nLb6CoED4E89G LAeXJQh46xD9kYcEx2NnaqK5DMuR9iVb2SmjfSr9sxGYtd2uthOF5k+fHI/17NBu4/IQ +ZfOt8nYtfCooOewAf2pwvYapqGGxVSBkrQhVipnfaZ0i1bDpX3pbRlAa/kMutJ76kdj TqQ61K4zxK79ra1GDRTsQRb+xeQLG5Mx6mJmEdsV7hfKJAv7cIoYOAzaBjbK1dfiZM9e cpeMN7rh2qNgPFsS89CRN8UhAV0sPBargdvJTX2Ks7bcT3sxTlXzVP03PtZKbOHQtbN6 VKig== X-Gm-Message-State: AOAM533xqJx6i/mbZ3Qe0RE+OlvuF49pDm9SlwB5Fixxo63/udZCMmdb wJ1Sew6/zVEI6Lne1vkXSMlC6N1hxhdYrBr9 X-Google-Smtp-Source: ABdhPJxdknZq9AOLh/8q+YvhUwmgvr0vwr2MdB2X8Mu8Hy9b+nUwzyLxAKLMh14k9jwRZi+I9po8Mg== X-Received: by 2002:aa7:cd71:: with SMTP id ca17mr7226916edb.25.1607364133485; Mon, 07 Dec 2020 10:02:13 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id be6sm14657977edb.29.2020.12.07.10.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 10:02:08 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 7 Dec 2020 18:01:18 +0000 Message-Id: <20201207180121.6374-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201207180121.6374-1-david.plowman@raspberrypi.com> References: <20201207180121.6374-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/6] src: ipa: raspberrypi: agc: 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 | 13 +++++++++++++ src/ipa/raspberrypi/controller/rpi/awb.hpp | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/ipa/raspberrypi/controller/awb_algorithm.hpp b/src/ipa/raspberrypi/controller/awb_algorithm.hpp index 5be0c9f4..84ae313b 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(unsigned int mistrust_frames) 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..6b359ac5 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,18 @@ void Awb::Initialise() prev_sync_results_ = sync_results_; } +unsigned int Awb::GetConvergenceFrames(unsigned int mistrust_frames) const +{ + // If colour gains have been explicitly set, there is no convergence + // to happen, so no need to drop any frames - return zero. + // Otherwise, any frames for which we have been told not to trust the + // statistics must be added to our own count. + if (manual_r_ && manual_b_) + return 0; + else + return config_.convergence_frames + mistrust_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..d86b9598 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(unsigned int mistrust_frames) 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;