[{"id":14127,"web_url":"https://patchwork.libcamera.org/comment/14127/","msgid":"<CAEmqJPqWxEousSdVdUu5gV_8jyYPEMvuwSTA2XRXxXPOsPHaKQ@mail.gmail.com>","date":"2020-12-08T10:08:11","subject":"Re: [libcamera-devel] [PATCH v2 3/6] src: ipa: raspberrypi: agc:\n\tAdd GetConvergenceFrames method to AWB base class","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nThank you for your patch.\n\nOn Mon, 7 Dec 2020 at 18:02, David Plowman <david.plowman@raspberrypi.com>\nwrote:\n\n> We add a GetConvergenceFrames method to the AwbAlgorithm class which\n> can be called when the AWB is started from scratch. It suggests how\n> many frames should be dropped before displaying any (while the AWB\n> converges).\n>\n> The Raspberry Pi specific implementation makes this customisable from\n> the tuning file.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/controller/awb_algorithm.hpp |  1 +\n>  src/ipa/raspberrypi/controller/rpi/awb.cpp       | 13 +++++++++++++\n>  src/ipa/raspberrypi/controller/rpi/awb.hpp       |  2 ++\n>  3 files changed, 16 insertions(+)\n>\n> diff --git a/src/ipa/raspberrypi/controller/awb_algorithm.hpp\n> b/src/ipa/raspberrypi/controller/awb_algorithm.hpp\n> index 5be0c9f4..84ae313b 100644\n> --- a/src/ipa/raspberrypi/controller/awb_algorithm.hpp\n> +++ b/src/ipa/raspberrypi/controller/awb_algorithm.hpp\n> @@ -15,6 +15,7 @@ class AwbAlgorithm : public Algorithm\n>  public:\n>         AwbAlgorithm(Controller *controller) : Algorithm(controller) {}\n>         // An AWB algorithm must provide the following:\n> +       virtual unsigned int GetConvergenceFrames(unsigned int\n> mistrust_frames) const = 0;\n>         virtual void SetMode(std::string const &mode_name) = 0;\n>         virtual void SetManualGains(double manual_r, double manual_b) = 0;\n>  };\n> diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp\n> b/src/ipa/raspberrypi/controller/rpi/awb.cpp\n> index 020825e3..6b359ac5 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp\n> @@ -59,6 +59,7 @@ void AwbConfig::Read(boost::property_tree::ptree const\n> &params)\n>         bayes = params.get<int>(\"bayes\", 1);\n>         frame_period = params.get<uint16_t>(\"frame_period\", 10);\n>         startup_frames = params.get<uint16_t>(\"startup_frames\", 10);\n> +       convergence_frames = params.get<unsigned\n> int>(\"convergence_frames\", 3);\n>         speed = params.get<double>(\"speed\", 0.05);\n>         if (params.get_child_optional(\"ct_curve\"))\n>                 read_ct_curve(ct_r, ct_b, params.get_child(\"ct_curve\"));\n> @@ -165,6 +166,18 @@ void Awb::Initialise()\n>         prev_sync_results_ = sync_results_;\n>  }\n>\n> +unsigned int Awb::GetConvergenceFrames(unsigned int mistrust_frames) const\n> +{\n> +       // If colour gains have been explicitly set, there is no\n> convergence\n> +       // to happen, so no need to drop any frames - return zero.\n> +       // Otherwise, any frames for which we have been told not to trust\n> the\n> +       // statistics must be added to our own count.\n> +       if (manual_r_ && manual_b_)\n> +               return 0;\n> +       else\n> +               return config_.convergence_frames + mistrust_frames;\n> +}\n> +\n>\n\nSimilar to the comment on the AGC patch, could you not leave\nmistrust_frames out and do the addition of mistrust frames in the IPA?\nEither way,\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n>  void Awb::SetMode(std::string const &mode_name)\n>  {\n>         std::unique_lock<std::mutex> lock(settings_mutex_);\n> diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp\n> b/src/ipa/raspberrypi/controller/rpi/awb.hpp\n> index 545d85a8..d86b9598 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp\n> @@ -37,6 +37,7 @@ struct AwbConfig {\n>         uint16_t frame_period;\n>         // number of initial frames for which speed taken as 1.0 (maximum)\n>         uint16_t startup_frames;\n> +       unsigned int convergence_frames; // approx number of frames to\n> converge\n>         double speed; // IIR filter speed applied to algorithm results\n>         bool fast; // \"fast\" mode uses a 16x16 rather than 32x32 grid\n>         Pwl ct_r; // function maps CT to r (= R/G)\n> @@ -82,6 +83,7 @@ public:\n>         char const *Name() const override;\n>         void Initialise() override;\n>         void Read(boost::property_tree::ptree const &params) override;\n> +       unsigned int GetConvergenceFrames(unsigned int mistrust_frames)\n> const override;\n>         void SetMode(std::string const &name) override;\n>         void SetManualGains(double manual_r, double manual_b) override;\n>         void SwitchMode(CameraMode const &camera_mode, Metadata *metadata)\n> override;\n> --\n> 2.20.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4C592BDB1F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Dec 2020 10:08:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1429D67E6E;\n\tTue,  8 Dec 2020 11:08:32 +0100 (CET)","from mail-lf1-x136.google.com (mail-lf1-x136.google.com\n\t[IPv6:2a00:1450:4864:20::136])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE29D635F2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Dec 2020 11:08:30 +0100 (CET)","by mail-lf1-x136.google.com with SMTP id u18so22206097lfd.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Dec 2020 02:08:30 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"n4w+q6xj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=hLYTyh/3lxRIc2zmizUHhwbVsI+NM/3zn6h5txgrF64=;\n\tb=n4w+q6xjFr2gveFO3DWww75gIS/jsZvP/Ov/PERnoS5pSJbGD2tl4hB1sX0Y9C9Lth\n\tJwvNm9+ssD69txOMZU7K4SymaHm5Hu0BUH7wslDIZCwV683Qb2IE6HKKik0iGD2IgQEW\n\tiAy3X2VwfyBV319QtLAbfCvzhEPzZ/wxpA6MbR4QDJryELfRqzt36ezDtQwN7JDQF1+2\n\tqL3T+uwze+daYi3wZRKCEgtZcNcR3QkfT0DDnPaf8N+4KLgtfqiUuQBKHqlbPMIkKIKP\n\tDismXG/bldS4QEx/05Rty/YU5zOSDnkpxkcAXzMi6+ZXhXYlfcIU+gk1p0qR841ou3p6\n\thNXw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=hLYTyh/3lxRIc2zmizUHhwbVsI+NM/3zn6h5txgrF64=;\n\tb=uI/rnM3/tHBl9y1cYRpwylgNWVQTZF93YKtHi6UbnR7C5QJ7H7Vfh3kL0xkfhAMrWw\n\tIKL5Sxt062AgKq/UOaFrAU9+DTJsTnHexw7DmxZvAQGNj/6YMOQKqu/vZ2C1vM+8eu+g\n\tr+oPJs39dPGixZ5yH1gJlM/FqV5Adv2cxvcn4HhIsqhxIUDSZa9rPEwZy06z49MZqri4\n\thF9O4K0RxlT/NTZR5EFt/B6PI286Nvqp0YDY96LdzckmuGXFbmZA5sjIACUQ/f1Wz8fU\n\thwJJV6oIOxC/ydwBY/QSwIii/+q9tRf93v8TOIo22FhDssyY5D2h65XNH8W3aNXw1Wj6\n\tJwOg==","X-Gm-Message-State":"AOAM531rt/7MaBCRENtLQiTzQzpqzCom/87aFf/m7vJ7NqIMxpdimpsH\n\tezhEMSCEy/r3RgfOsd7rBFPhmcbgcQ+A2+lP6pa1kA==","X-Google-Smtp-Source":"ABdhPJyhiI535NQiULIG1qqSb4hqFuvxwfyrmZpSTNDuUM6/kEdcrJ2wMYR6g/XFs9/5yqtYSeuQuALu7BKWhWoNa28=","X-Received":"by 2002:a19:7f90:: with SMTP id a138mr62482lfd.617.1607422110185;\n\tTue, 08 Dec 2020 02:08:30 -0800 (PST)","MIME-Version":"1.0","References":"<20201207180121.6374-1-david.plowman@raspberrypi.com>\n\t<20201207180121.6374-4-david.plowman@raspberrypi.com>","In-Reply-To":"<20201207180121.6374-4-david.plowman@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Tue, 8 Dec 2020 10:08:11 +0000","Message-ID":"<CAEmqJPqWxEousSdVdUu5gV_8jyYPEMvuwSTA2XRXxXPOsPHaKQ@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 3/6] src: ipa: raspberrypi: agc:\n\tAdd GetConvergenceFrames method to AWB base class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"multipart/mixed;\n\tboundary=\"===============8955739706682907503==\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14138,"web_url":"https://patchwork.libcamera.org/comment/14138/","msgid":"<X89l0uUuOBwZy+i9@pendragon.ideasonboard.com>","date":"2020-12-08T11:38:58","subject":"Re: [libcamera-devel] [PATCH v2 3/6] src: ipa: raspberrypi: agc:\n\tAdd GetConvergenceFrames method to AWB base class","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Mon, Dec 07, 2020 at 06:01:18PM +0000, David Plowman wrote:\n> We add a GetConvergenceFrames method to the AwbAlgorithm class which\n> can be called when the AWB is started from scratch. It suggests how\n> many frames should be dropped before displaying any (while the AWB\n> converges).\n> \n> The Raspberry Pi specific implementation makes this customisable from\n> the tuning file.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/ipa/raspberrypi/controller/awb_algorithm.hpp |  1 +\n>  src/ipa/raspberrypi/controller/rpi/awb.cpp       | 13 +++++++++++++\n>  src/ipa/raspberrypi/controller/rpi/awb.hpp       |  2 ++\n>  3 files changed, 16 insertions(+)\n> \n> diff --git a/src/ipa/raspberrypi/controller/awb_algorithm.hpp b/src/ipa/raspberrypi/controller/awb_algorithm.hpp\n> index 5be0c9f4..84ae313b 100644\n> --- a/src/ipa/raspberrypi/controller/awb_algorithm.hpp\n> +++ b/src/ipa/raspberrypi/controller/awb_algorithm.hpp\n> @@ -15,6 +15,7 @@ class AwbAlgorithm : public Algorithm\n>  public:\n>  \tAwbAlgorithm(Controller *controller) : Algorithm(controller) {}\n>  \t// An AWB algorithm must provide the following:\n> +\tvirtual unsigned int GetConvergenceFrames(unsigned int mistrust_frames) const = 0;\n>  \tvirtual void SetMode(std::string const &mode_name) = 0;\n>  \tvirtual void SetManualGains(double manual_r, double manual_b) = 0;\n>  };\n> diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp\n> index 020825e3..6b359ac5 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp\n> @@ -59,6 +59,7 @@ void AwbConfig::Read(boost::property_tree::ptree const &params)\n>  \tbayes = params.get<int>(\"bayes\", 1);\n>  \tframe_period = params.get<uint16_t>(\"frame_period\", 10);\n>  \tstartup_frames = params.get<uint16_t>(\"startup_frames\", 10);\n> +\tconvergence_frames = params.get<unsigned int>(\"convergence_frames\", 3);\n>  \tspeed = params.get<double>(\"speed\", 0.05);\n>  \tif (params.get_child_optional(\"ct_curve\"))\n>  \t\tread_ct_curve(ct_r, ct_b, params.get_child(\"ct_curve\"));\n> @@ -165,6 +166,18 @@ void Awb::Initialise()\n>  \tprev_sync_results_ = sync_results_;\n>  }\n>  \n> +unsigned int Awb::GetConvergenceFrames(unsigned int mistrust_frames) const\n> +{\n> +\t// If colour gains have been explicitly set, there is no convergence\n> +\t// to happen, so no need to drop any frames - return zero.\n> +\t// Otherwise, any frames for which we have been told not to trust the\n> +\t// statistics must be added to our own count.\n> +\tif (manual_r_ && manual_b_)\n> +\t\treturn 0;\n> +\telse\n> +\t\treturn config_.convergence_frames + mistrust_frames;\n> +}\n> +\n>  void Awb::SetMode(std::string const &mode_name)\n>  {\n>  \tstd::unique_lock<std::mutex> lock(settings_mutex_);\n> diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp\n> index 545d85a8..d86b9598 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp\n> @@ -37,6 +37,7 @@ struct AwbConfig {\n>  \tuint16_t frame_period;\n>  \t// number of initial frames for which speed taken as 1.0 (maximum)\n>  \tuint16_t startup_frames;\n> +\tunsigned int convergence_frames; // approx number of frames to converge\n>  \tdouble speed; // IIR filter speed applied to algorithm results\n>  \tbool fast; // \"fast\" mode uses a 16x16 rather than 32x32 grid\n>  \tPwl ct_r; // function maps CT to r (= R/G)\n> @@ -82,6 +83,7 @@ public:\n>  \tchar const *Name() const override;\n>  \tvoid Initialise() override;\n>  \tvoid Read(boost::property_tree::ptree const &params) override;\n> +\tunsigned int GetConvergenceFrames(unsigned int mistrust_frames) const override;\n>  \tvoid SetMode(std::string const &name) override;\n>  \tvoid SetManualGains(double manual_r, double manual_b) override;\n>  \tvoid SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override;","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7CD52BDB1F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Dec 2020 11:39:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 43DAD67E6D;\n\tTue,  8 Dec 2020 12:39:03 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 41181600FF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Dec 2020 12:39:02 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7DED2DD;\n\tTue,  8 Dec 2020 12:39:01 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"pQVlT9dp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1607427541;\n\tbh=FPOD/EwY5j5YQGq0S10PnZzOjNH6nRPuNdVvISxMIQY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=pQVlT9dpQUmI2kUOB7nUW6HC199rMfJ1PlCjMymxD8BUQpbjs6ltK6H3Cg1Eyzo47\n\tih6+rFMQfwNaiV37Ofzy2ULWaYvBibGAggMoLfPl/dH6CYDoKTuM5nILfIJgwaNVbi\n\ttoA/hbGeS2KWBMsqMMXz/h+4/WXctqgdyDQY9b+A=","Date":"Tue, 8 Dec 2020 13:38:58 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<X89l0uUuOBwZy+i9@pendragon.ideasonboard.com>","References":"<20201207180121.6374-1-david.plowman@raspberrypi.com>\n\t<20201207180121.6374-4-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201207180121.6374-4-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 3/6] src: ipa: raspberrypi: agc:\n\tAdd GetConvergenceFrames method to AWB base class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]