Patch Detail
Show a patch.
GET /api/patches/18435/?format=api
{ "id": 18435, "url": "https://patchwork.libcamera.org/api/patches/18435/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18435/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20230322130612.5208-9-naush@raspberrypi.com>", "date": "2023-03-22T13:06:10", "name": "[libcamera-devel,v1,08/10] ipa: raspberrypi: Generalise the focus algorithm", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a1ef6d6b324391fd6acee38881e3664156f03432", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18435/mbox/", "series": [ { "id": 3810, "url": "https://patchwork.libcamera.org/api/series/3810/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3810", "date": "2023-03-22T13:06:02", "name": "Raspberry Pi: Generalised algorithms", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3810/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18435/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18435/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 4CDDBC32A1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Mar 2023 13:06:31 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C8EF76273D;\n\tWed, 22 Mar 2023 14:06:30 +0100 (CET)", "from mail-io1-xd32.google.com (mail-io1-xd32.google.com\n\t[IPv6:2607:f8b0:4864:20::d32])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CCA0B62716\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Mar 2023 14:06:26 +0100 (CET)", "by mail-io1-xd32.google.com with SMTP id s4so8386058ioj.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Mar 2023 06:06:26 -0700 (PDT)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tl6-20020a026646000000b003c488204c6fsm4927960jaf.76.2023.03.22.06.06.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 22 Mar 2023 06:06:25 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679490390;\n\tbh=vly+N8kD070ySftpvX91l+mQboT8yWAuvyihR8zCM34=;\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=aV59BNqEI8iuNUQnhZIv1NY0sSsjA/OTOii03Ge+WT+YrVav/1PZhJAlRJzTcGw0D\n\tOJElfp/sDLhkjpXlclBqgl+DNbn0T/c6RSU6T3sjsfrmWZW7AK1cbAn19hSiUwvhXY\n\tC/on0DqaKYB9TnhP8eqVTeaotl8627HSH8RHzdt/kqNckCcAwKALPT5Vsc4lnO0IR4\n\tmqqjPsCqM+lf3NK+w5v+g0HPezz/vPNWE1nQONfcDGJGUa9FobRkBjSwF9cHOt4Eyj\n\tRQos0exCsB1wCTWhtV1tfUodFnVWXptvmml0kXdjcLyUUyWEwxwLYtUW8ST1GAZZfs\n\tiVF4TDkANh0eg==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1679490386;\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=VTK7RKvARCpPhRDMEiuWMbT7meHOFDF62AOEWuoNos8=;\n\tb=pd246ll/74pNccmnICdWx6Jm4G0Y0+Irarb3wx3Sze12V7FSCnk1mHr8z+xG6QSaEX\n\tqPIW3QqOZXJQJwgBOI/+kXGVV/PfD40qly+jUjj/z1VOAio2wbgEa1xB4/7R12Idc6zD\n\tu5dxiYT7Fd3y117eOoOqwPYILkMnM7Bs/upnxWixfEiv8Zb2RajjUIiMi8sFCvKZyrqF\n\txvj1TV5QW6rwrCpDPnH+YOkPcqqyttqNAai79KlE96tjGxt2Hew62agqGxoKrAlheQK6\n\t3y7AVyvt8PUiZ+PCH7kKKGZ8bJp2pYUhFHIU3UcP51U93snhfqOEFwMchQn0sbbdjzR+\n\tAZMA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"pd246ll/\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1679490386;\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=VTK7RKvARCpPhRDMEiuWMbT7meHOFDF62AOEWuoNos8=;\n\tb=XnBeoi2nBoCo3vzWfaYvjQsSvlg3/jqqxIwgOsYPw8fGOMr0kxSIL8yNnFTC/Y/uxF\n\t0WzVQeuIebSsiU8wjIHYoVuPAJ4ca4P7tRlBwb9p/I8dMArxdFaJcL5kgu7S8ExdmfDA\n\tFhyXV3BmFMFR7PDNSFwxRloeaGVUg46u+sqFQCjBre+v4sg+OPdrMpWEecVpw3FFdAQv\n\tZQNiQqHhG47B3jnrEo7AZj5tLg7OyaECJe634XCKMhusf4wIJfH7ufmfOP1o0OI1fJUn\n\tJzcc3m4FGbCq0NlUVUAdFCwUyAcTfoHvXqsqIgwSETxMdOpfIW4RELXaiTTuM9WJXeC8\n\tmyFA==", "X-Gm-Message-State": "AO0yUKWx8IrId0zG/4PH4yTEYfj82aVFcv4a++S5U26AqACrHyi0Onp2\n\te+eq65VDzGAsuvoulkzGzRhxdQZC4XcEUVbX4cWsbA==", "X-Google-Smtp-Source": "AK7set+cjpe2x/LRyuaMf/dDNdqDoD3bC5YsNufoGxaKAceILUGhko88mBp9gnE7n55sI7G8xbCsjw==", "X-Received": "by 2002:a5e:db02:0:b0:746:1c75:233a with SMTP id\n\tq2-20020a5edb02000000b007461c75233amr4547901iop.20.1679490386244; \n\tWed, 22 Mar 2023 06:06:26 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 22 Mar 2023 13:06:10 +0000", "Message-Id": "<20230322130612.5208-9-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20230322130612.5208-1-naush@raspberrypi.com>", "References": "<20230322130612.5208-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v1 08/10] ipa: raspberrypi: Generalise the\n\tfocus algorithm", "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": "Generalise the focus reporting algorithm code by removing any hard-coded\nassumptions about the target hardware platform. Instead, the algorithm\ncode uses the generalised statistics structure to determine focus region\nsizes.\n\nRemove focus_status.h as it is no longer needed with this change.\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/focus.cpp | 12 ++---------\n src/ipa/raspberrypi/raspberrypi.cpp | 11 ++++++----\n 3 files changed, 9 insertions(+), 34 deletions(-)\n delete mode 100644 src/ipa/raspberrypi/controller/focus_status.h", "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/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp\nindex ea3cc00e42c3..683d460ad6f7 100644\n--- a/src/ipa/raspberrypi/controller/rpi/focus.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp\n@@ -8,7 +8,6 @@\n \n #include <libcamera/base/log.h>\n \n-#include \"../focus_status.h\"\n #include \"focus.h\"\n \n using namespace RPiController;\n@@ -30,15 +29,8 @@ char const *Focus::name() const\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+\t/* Pass the stats directly to the IPA to report out to the application */\n+\timageMetadata->set(\"focus.status\", stats->focusRegions);\n }\n \n /* Register algorithm with the system. */\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex b6e5465ca32a..181512de74ad 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@@ -640,14 +639,18 @@ 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\tlibcamera::Size size = focusStatus->size();\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 */\n-\t\tint32_t focusFoM = (focusStatus->focusMeasures[5] + focusStatus->focusMeasures[6]) / 2;\n+\t\tASSERT(size == Size(4, 3));\n+\t\tint32_t focusFoM = (focusStatus->get({ 1, 1 }).val +\n+\t\t\t\t focusStatus->get({ 2, 1 }).val) / 2;\n \t\tlibcameraMetadata_.set(controls::FocusFoM, focusFoM);\n \t}\n \n", "prefixes": [ "libcamera-devel", "v1", "08/10" ] }