{"id":18506,"url":"https://patchwork.libcamera.org/api/1.1/patches/18506/?format=json","web_url":"https://patchwork.libcamera.org/patch/18506/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230331072341.24851-11-naush@raspberrypi.com>","date":"2023-03-31T07:23:41","name":"[libcamera-devel,v3,10/10] ipa: raspberrypi: Generalise the focus reporting code","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"dc193e4571644ee5af4a049bde5cbcb0f127cdd7","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18506/mbox/","series":[{"id":3830,"url":"https://patchwork.libcamera.org/api/1.1/series/3830/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3830","date":"2023-03-31T07:23:31","name":"Raspberry Pi: Generalised algorithms","version":3,"mbox":"https://patchwork.libcamera.org/series/3830/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18506/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18506/checks/","tags":{},"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 F1457C32A1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 Mar 2023 07:41:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5AEC4627B0;\n\tFri, 31 Mar 2023 09:41:02 +0200 (CEST)","from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com\n\t[IPv6:2607:f8b0:4864:20::d2c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E4A16276B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Mar 2023 09:40:59 +0200 (CEST)","by mail-io1-xd2c.google.com with SMTP id o10so1231259iou.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Mar 2023 00:40:59 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ti17-20020a6bf411000000b0074555814e73sm421943iog.32.2023.03.31.00.40.57\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 31 Mar 2023 00:40:58 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1680248462;\n\tbh=Gv6rqzTKA+31wd9768EnOreD8gtbkn7EyWRda1EDJMk=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=wHBFS6Nojgs4chzCU+PcHA8TOuT/m1zXC9mfhol3QzOcG7+NY2wFL09PGiipoeNId\n\tc5mu1T+3QfSdkDDXNbuWT58F6qZ89h6BEMAsa9gZg38HB8mj+gMVboMaAiRlwj4+wd\n\tGtBHxn2Nvek8/K7SkWsODSYbd2TS6wGmX0RzbYPwme0ykxU6KDiqEfIESeVRsbDIlI\n\taE/7qu4+aRjGDlw94x94zW+itSBWONlIMP0j1fegdEmfhfHd74nElzAa4vgjObM9W7\n\tMOpjICSlKolC4Snq6h6908qNpRp18ZDutvokwANYor3G3ylHqwI3qoviGPi5/V/n82\n\tcmx5BP9b1qLQA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1680248458;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=UFZiwfMADtRs4OW/isIommDAqrPPblljCYn15JQKc4o=;\n\tb=CaWTvZY76PwYFhw1Fexrh4zOmVn0mdeiBjsx/SCGb5jtqdxSGw+6nbl1sIlrnOXwso\n\t8BYEVzAdBw0O9fsiKuHYPX4IV7WgloGWrWeFDOG8SsCN7q9O414R6yq0sAANiP4NgL7X\n\tgPimLXzNi4PxshYyXRbSHSCRF/9IULkW2P9ALi1NM4MNgPjbihQgIyyUIdwbEuomQI11\n\tVJT/esJ9DjfSomKq0b89Hcfq8NV+Ak2gCQILxf5876ONUyaQczljNuVzPsaOrSL6mrQw\n\t4fqDRSBTbzj5QstABrMYYul5RhHdBy56itB+WO4FHXwmBgqTeNxlgWsnwo4+UUpIrsOk\n\t28mw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"CaWTvZY7\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1680248458;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=UFZiwfMADtRs4OW/isIommDAqrPPblljCYn15JQKc4o=;\n\tb=ER3xgn3oXFUPqL/6487cN6YdPUo1Zua8dM3s8uh9K6gp/JQVQ8dyBHBgJ+1YvBqa3G\n\tZARgAPFG8KtZTAvJBWFBXu6xcGtYDPnioBWkBMCvA9eLn87h3WZ9skY3Z8Rg8i4b6LBZ\n\tV/xM2lLioZRE761YIgAcXWNfKFTAMnJIsDZbsOBKURQFZJgH0GpvXEUq6SrJiP+Ngalw\n\tU5lhFqvLYBC9OrgdKlTZJbwMnXPuXF6yVTSLExat1FneDW7gP/N3Z62X/f5T4ITJSTN9\n\tbUmmq8AkJ+figLS1IYmuYJzANPHEYFhSfamPBLDEwytJ5VkGnRQfdfD5DZqfHQ1ZkXg5\n\tT/gQ==","X-Gm-Message-State":"AAQBX9cJgFAxerP3tOHmKYeUGgzKOc+I84sGS+k2AzYdTjS1EePIG1GI\n\tfo/y1TNq3w1YEMFyrlBDe+sei4ahrOER+Ncrfq0i7Q==","X-Google-Smtp-Source":"AKy350ZzstqJf9assJZ8bm8eUTOkPeUst9spAI43KMIEPIUUBTnlGeVldxlFME3LZGomUMXuYdpDGA==","X-Received":"by 2002:a6b:ce16:0:b0:75d:b1:b718 with SMTP id\n\tp22-20020a6bce16000000b0075d00b1b718mr3093279iob.9.1680248458377; \n\tFri, 31 Mar 2023 00:40:58 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 31 Mar 2023 08:23:41 +0100","Message-Id":"<20230331072341.24851-11-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20230331072341.24851-1-naush@raspberrypi.com>","References":"<20230331072341.24851-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 10/10] ipa: raspberrypi: Generalise the\n\tfocus reporting code","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Use the generalised focus statistics structure to compute the centre\nwindow focus FoM value. This avoids needed to hard-code a specific\ngrid size.\n\nRemove the focus reporting algorithm as the functionality is duplicated\nby this bit of IPA code. Remove focus_status.h as it is no longer needed.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/focus_status.h | 20 --------\n src/ipa/raspberrypi/controller/rpi/af.h       |  1 -\n src/ipa/raspberrypi/controller/rpi/focus.cpp  | 49 -------------------\n src/ipa/raspberrypi/data/imx290.json          |  3 --\n src/ipa/raspberrypi/data/imx296.json          |  3 --\n src/ipa/raspberrypi/data/imx296_mono.json     |  3 --\n src/ipa/raspberrypi/data/imx477.json          |  3 --\n src/ipa/raspberrypi/data/imx477_noir.json     |  3 --\n .../raspberrypi/data/imx477_scientific.json   |  3 --\n src/ipa/raspberrypi/data/imx477_v1.json       |  3 --\n src/ipa/raspberrypi/data/imx708.json          |  3 --\n src/ipa/raspberrypi/data/imx708_noir.json     |  3 --\n src/ipa/raspberrypi/data/imx708_wide.json     |  3 --\n .../raspberrypi/data/imx708_wide_noir.json    |  3 --\n src/ipa/raspberrypi/meson.build               |  1 -\n src/ipa/raspberrypi/raspberrypi.cpp           | 32 +++++++++---\n 16 files changed, 24 insertions(+), 112 deletions(-)\n delete mode 100644 src/ipa/raspberrypi/controller/focus_status.h\n delete mode 100644 src/ipa/raspberrypi/controller/rpi/focus.cpp","diff":"diff --git a/src/ipa/raspberrypi/controller/focus_status.h b/src/ipa/raspberrypi/controller/focus_status.h\ndeleted file mode 100644\nindex 8b74e59840c1..000000000000\n--- a/src/ipa/raspberrypi/controller/focus_status.h\n+++ /dev/null\n@@ -1,20 +0,0 @@\n-/* SPDX-License-Identifier: BSD-2-Clause */\n-/*\n- * Copyright (C) 2020, Raspberry Pi Ltd\n- *\n- * focus_status.h - focus measurement status\n- */\n-#pragma once\n-\n-#include <linux/bcm2835-isp.h>\n-\n-/*\n- * The focus algorithm should post the following structure into the image's\n- * \"focus.status\" metadata. Recall that it's only reporting focus (contrast)\n- * measurements, it's not driving any kind of auto-focus algorithm!\n- */\n-\n-struct FocusStatus {\n-\tunsigned int num;\n-\tuint32_t focusMeasures[FOCUS_REGIONS];\n-};\ndiff --git a/src/ipa/raspberrypi/controller/rpi/af.h b/src/ipa/raspberrypi/controller/rpi/af.h\nindex b479feb88c39..6d2bae671a22 100644\n--- a/src/ipa/raspberrypi/controller/rpi/af.h\n+++ b/src/ipa/raspberrypi/controller/rpi/af.h\n@@ -28,7 +28,6 @@\n  * \"nuisance\" scans. During each interval where PDAF is not working, only\n  * ONE scan will be performed; CAF cannot track objects using CDAF alone.\n  *\n- * This algorithm is unrelated to \"rpi.focus\" which merely reports CDAF FoM.\n  */\n \n namespace RPiController {\ndiff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp\ndeleted file mode 100644\nindex ea3cc00e42c3..000000000000\n--- a/src/ipa/raspberrypi/controller/rpi/focus.cpp\n+++ /dev/null\n@@ -1,49 +0,0 @@\n-/* SPDX-License-Identifier: BSD-2-Clause */\n-/*\n- * Copyright (C) 2020, Raspberry Pi Ltd\n- *\n- * focus.cpp - focus algorithm\n- */\n-#include <stdint.h>\n-\n-#include <libcamera/base/log.h>\n-\n-#include \"../focus_status.h\"\n-#include \"focus.h\"\n-\n-using namespace RPiController;\n-using namespace libcamera;\n-\n-LOG_DEFINE_CATEGORY(RPiFocus)\n-\n-#define NAME \"rpi.focus\"\n-\n-Focus::Focus(Controller *controller)\n-\t: Algorithm(controller)\n-{\n-}\n-\n-char const *Focus::name() const\n-{\n-\treturn NAME;\n-}\n-\n-void Focus::process(StatisticsPtr &stats, Metadata *imageMetadata)\n-{\n-\tFocusStatus status;\n-\tfor (unsigned int i = 0; i < stats->focusRegions.numRegions(); i++)\n-\t\tstatus.focusMeasures[i] = stats->focusRegions.get(i).val;\n-\tstatus.num = stats->focusRegions.numRegions();\n-\timageMetadata->set(\"focus.status\", status);\n-\n-\tLOG(RPiFocus, Debug)\n-\t\t<< \"Focus contrast measure: \"\n-\t\t<< (status.focusMeasures[5] + status.focusMeasures[6]) / 10;\n-}\n-\n-/* Register algorithm with the system. */\n-static Algorithm *create(Controller *controller)\n-{\n-\treturn new Focus(controller);\n-}\n-static RegisterAlgorithm reg(NAME, &create);\ndiff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json\nindex bfb9c6093d26..ace68d0ebf1c 100644\n--- a/src/ipa/raspberrypi/data/imx290.json\n+++ b/src/ipa/raspberrypi/data/imx290.json\n@@ -195,9 +195,6 @@\n                     }\n                 ]\n             }\n-        },\n-        {\n-            \"rpi.focus\": { }\n         }\n     ]\n }\n\\ No newline at end of file\ndiff --git a/src/ipa/raspberrypi/data/imx296.json b/src/ipa/raspberrypi/data/imx296.json\nindex 346f5b658957..ae8722c46a85 100644\n--- a/src/ipa/raspberrypi/data/imx296.json\n+++ b/src/ipa/raspberrypi/data/imx296.json\n@@ -532,9 +532,6 @@\n                 \"strength\": 1.0,\n                 \"limit\": 0.18\n             }\n-        },\n-        {\n-            \"rpi.focus\": { }\n         }\n     ]\n }\ndiff --git a/src/ipa/raspberrypi/data/imx296_mono.json b/src/ipa/raspberrypi/data/imx296_mono.json\nindex e9fa30c6a08d..30965b4b8d61 100644\n--- a/src/ipa/raspberrypi/data/imx296_mono.json\n+++ b/src/ipa/raspberrypi/data/imx296_mono.json\n@@ -228,9 +228,6 @@\n                 \"strength\": 1.0,\n                 \"limit\": 0.18\n             }\n-        },\n-        {\n-            \"rpi.focus\": { }\n         }\n     ]\n }\ndiff --git a/src/ipa/raspberrypi/data/imx477.json b/src/ipa/raspberrypi/data/imx477.json\nindex bfc0774ffdfc..daffc268ff43 100644\n--- a/src/ipa/raspberrypi/data/imx477.json\n+++ b/src/ipa/raspberrypi/data/imx477.json\n@@ -513,9 +513,6 @@\n         },\n         {\n             \"rpi.sharpen\": { }\n-        },\n-        {\n-            \"rpi.focus\": { }\n         }\n     ]\n }\n\\ No newline at end of file\ndiff --git a/src/ipa/raspberrypi/data/imx477_noir.json b/src/ipa/raspberrypi/data/imx477_noir.json\nindex dadd97bc3d78..52d7f072d0ce 100644\n--- a/src/ipa/raspberrypi/data/imx477_noir.json\n+++ b/src/ipa/raspberrypi/data/imx477_noir.json\n@@ -424,9 +424,6 @@\n         },\n         {\n             \"rpi.sharpen\": { }\n-        },\n-        {\n-            \"rpi.focus\": { }\n         }\n     ]\n }\n\\ No newline at end of file\ndiff --git a/src/ipa/raspberrypi/data/imx477_scientific.json b/src/ipa/raspberrypi/data/imx477_scientific.json\nindex 17c4ed0a5e74..26c692fdbab9 100644\n--- a/src/ipa/raspberrypi/data/imx477_scientific.json\n+++ b/src/ipa/raspberrypi/data/imx477_scientific.json\n@@ -474,9 +474,6 @@\n         },\n         {\n             \"rpi.sharpen\": { }\n-        },\n-        {\n-            \"rpi.focus\": { }\n         }\n     ]\n }\n\\ No newline at end of file\ndiff --git a/src/ipa/raspberrypi/data/imx477_v1.json b/src/ipa/raspberrypi/data/imx477_v1.json\nindex 5bcaac67069b..d64020091efa 100644\n--- a/src/ipa/raspberrypi/data/imx477_v1.json\n+++ b/src/ipa/raspberrypi/data/imx477_v1.json\n@@ -511,9 +511,6 @@\n         },\n         {\n             \"rpi.sharpen\": { }\n-        },\n-        {\n-            \"rpi.focus\": { }\n         }\n     ]\n }\n\\ No newline at end of file\ndiff --git a/src/ipa/raspberrypi/data/imx708.json b/src/ipa/raspberrypi/data/imx708.json\nindex c38b2d4cf256..b9830a3bf692 100644\n--- a/src/ipa/raspberrypi/data/imx708.json\n+++ b/src/ipa/raspberrypi/data/imx708.json\n@@ -512,9 +512,6 @@\n         {\n             \"rpi.sharpen\": { }\n         },\n-        {\n-            \"rpi.focus\": { }\n-        },\n         {\n             \"rpi.af\":\n             {\ndiff --git a/src/ipa/raspberrypi/data/imx708_noir.json b/src/ipa/raspberrypi/data/imx708_noir.json\nindex 082274e34c53..075f70355cec 100644\n--- a/src/ipa/raspberrypi/data/imx708_noir.json\n+++ b/src/ipa/raspberrypi/data/imx708_noir.json\n@@ -512,9 +512,6 @@\n         {\n             \"rpi.sharpen\": { }\n         },\n-        {\n-            \"rpi.focus\": { }\n-        },\n         {\n             \"rpi.af\":\n             {\ndiff --git a/src/ipa/raspberrypi/data/imx708_wide.json b/src/ipa/raspberrypi/data/imx708_wide.json\nindex cdc61436995d..b772efee3b96 100644\n--- a/src/ipa/raspberrypi/data/imx708_wide.json\n+++ b/src/ipa/raspberrypi/data/imx708_wide.json\n@@ -403,9 +403,6 @@\n         {\n             \"rpi.sharpen\": { }\n         },\n-        {\n-            \"rpi.focus\": { }\n-        },\n         {\n             \"rpi.af\":\n             {\ndiff --git a/src/ipa/raspberrypi/data/imx708_wide_noir.json b/src/ipa/raspberrypi/data/imx708_wide_noir.json\nindex 8a7f59910833..c5f6b53dca7a 100644\n--- a/src/ipa/raspberrypi/data/imx708_wide_noir.json\n+++ b/src/ipa/raspberrypi/data/imx708_wide_noir.json\n@@ -403,9 +403,6 @@\n         {\n             \"rpi.sharpen\": { }\n         },\n-        {\n-            \"rpi.focus\": { }\n-        },\n         {\n             \"rpi.af\":\n             {\ndiff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\nindex 9230e17bca22..de78cbd80f9c 100644\n--- a/src/ipa/raspberrypi/meson.build\n+++ b/src/ipa/raspberrypi/meson.build\n@@ -33,7 +33,6 @@ rpi_ipa_sources = files([\n     'controller/rpi/awb.cpp',\n     'controller/rpi/sharpen.cpp',\n     'controller/rpi/black_level.cpp',\n-    'controller/rpi/focus.cpp',\n     'controller/rpi/geq.cpp',\n     'controller/rpi/noise.cpp',\n     'controller/rpi/lux.cpp',\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex e2662938c9d3..9f3f3ac3b15d 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -50,7 +50,6 @@\n #include \"denoise_algorithm.h\"\n #include \"denoise_status.h\"\n #include \"dpc_status.h\"\n-#include \"focus_status.h\"\n #include \"geq_status.h\"\n #include \"lux_status.h\"\n #include \"metadata.h\"\n@@ -642,14 +641,28 @@ void IPARPi::reportMetadata(unsigned int ipaContext)\n \t\t\t\t\t static_cast<int32_t>(blackLevelStatus->blackLevelG),\n \t\t\t\t\t static_cast<int32_t>(blackLevelStatus->blackLevelB) });\n \n-\tFocusStatus *focusStatus = rpiMetadata.getLocked<FocusStatus>(\"focus.status\");\n-\tif (focusStatus && focusStatus->num == 12) {\n+\tRPiController::FocusRegions *focusStatus =\n+\t\trpiMetadata.getLocked<RPiController::FocusRegions>(\"focus.status\");\n+\tif (focusStatus) {\n \t\t/*\n-\t\t * We get a 4x3 grid of regions by default. Calculate the average\n-\t\t * FoM over the central two positions to give an overall scene FoM.\n-\t\t * This can change later if it is not deemed suitable.\n+\t\t * Calculate the average FoM over the central (symmetric) positions\n+\t\t * to give an overall scene FoM. This can change later if it is\n+\t\t * not deemed suitable.\n \t\t */\n-\t\tint32_t focusFoM = (focusStatus->focusMeasures[5] + focusStatus->focusMeasures[6]) / 2;\n+\t\tlibcamera::Size size = focusStatus->size();\n+\t\tunsigned rows = size.height;\n+\t\tunsigned cols = size.width;\n+\n+\t\tuint64_t sum = 0;\n+\t\tunsigned int numRegions = 0;\n+\t\tfor (unsigned r = rows / 3; r < rows - rows / 3; ++r) {\n+\t\t\tfor (unsigned c = cols / 4; c < cols - cols / 4; ++c) {\n+\t\t\t\tsum += focusStatus->get({ (int)c, (int)r }).val;\n+\t\t\t\tnumRegions++;\n+\t\t\t}\n+\t\t}\n+\n+\t\tuint32_t focusFoM = (sum / numRegions) >> 16;\n \t\tlibcameraMetadata_.set(controls::FocusFoM, focusFoM);\n \t}\n \n@@ -1428,7 +1441,6 @@ RPiController::StatisticsPtr IPARPi::fillStatistics(bcm2835_isp_stats *stats) co\n \t\tstatistics->focusRegions.set(i, { stats->focus_stats[i].contrast_val[1][1] / 1000,\n \t\t\t\t\t\t  stats->focus_stats[i].contrast_val_num[1][1],\n \t\t\t\t\t\t  stats->focus_stats[i].contrast_val_num[1][0] });\n-\n \treturn statistics;\n }\n \n@@ -1445,6 +1457,10 @@ void IPARPi::processStats(unsigned int bufferId, unsigned int ipaContext)\n \tSpan<uint8_t> mem = it->second.planes()[0];\n \tbcm2835_isp_stats *stats = reinterpret_cast<bcm2835_isp_stats *>(mem.data());\n \tRPiController::StatisticsPtr statistics = fillStatistics(stats);\n+\n+\t/* Save the focus stats in the metadata structure to report out later. */\n+\trpiMetadata_[ipaContext].set(\"focus.status\", statistics->focusRegions);\n+\n \thelper_->process(statistics, rpiMetadata);\n \tcontroller_.process(statistics, &rpiMetadata);\n \n","prefixes":["libcamera-devel","v3","10/10"]}