{"id":15199,"url":"https://patchwork.libcamera.org/api/1.1/patches/15199/?format=json","web_url":"https://patchwork.libcamera.org/patch/15199/","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":"<20211221052507.2678322-2-paul.elder@ideasonboard.com>","date":"2021-12-21T05:25:06","name":"[libcamera-devel,1/2] controls: Add controls for lens shading maps","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"27b13aed1719a486d50a806f6702ace03447b719","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/users/17/?format=json","username":"epaul","first_name":"Paul","last_name":"Elder","email":"paul.elder@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/15199/mbox/","series":[{"id":2855,"url":"https://patchwork.libcamera.org/api/1.1/series/2855/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2855","date":"2021-12-21T05:25:05","name":"android: Lens shading","version":1,"mbox":"https://patchwork.libcamera.org/series/2855/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15199/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15199/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 70ED7C3258\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Dec 2021 05:25:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EFF35608F9;\n\tTue, 21 Dec 2021 06:25:22 +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 50387608E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Dec 2021 06:25:21 +0100 (CET)","from pyrite.mediacom.info (unknown\n\t[IPv6:2604:2d80:ad90:fb00:96fd:8874:873:6c16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 69FBFFD2;\n\tTue, 21 Dec 2021 06:25:20 +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=\"YM1CUrmZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1640064321;\n\tbh=9X06w33Dsa53G7mcjN4zL3DuXJBAYf7W+ICSjP/7sIc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=YM1CUrmZKKu1cRcavoxA1xBwvfaySduy6WbUfqVPOPvAP7hKoZYgvrpUDJdt9k3ST\n\t47T8SoRDTGF/+4MXiesLQlnn0MmoxQqRO8oMuhIq/OIxfAi3QeyVNgptOEDwB2mVxC\n\tz+CPNA0lPkS0h8NuWR/Dra+576f8Yf7HxoikKRHk=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 20 Dec 2021 23:25:06 -0600","Message-Id":"<20211221052507.2678322-2-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20211221052507.2678322-1-paul.elder@ideasonboard.com>","References":"<20211221052507.2678322-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/2] controls: Add controls for lens\n\tshading maps","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add controls related to lens shading maps:\n- For requesting the lens shading map to be reported\n- For reporting the lens shading map\n- For requesting that lens shading be applied, and to what degree\n\nPreviously only the first was available, as a draft control. Promote it\nto non-draft, upgrade the description, and add the other two.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/android/camera_capabilities.cpp |   2 +-\n src/libcamera/control_ids.yaml      | 141 +++++++++++++++++++++++++---\n 2 files changed, 128 insertions(+), 15 deletions(-)","diff":"diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp\nindex c716f4bf..742c6a6a 100644\n--- a/src/android/camera_capabilities.cpp\n+++ b/src/android/camera_capabilities.cpp\n@@ -1364,7 +1364,7 @@ int CameraCapabilities::initializeStaticMetadata()\n \t{\n \t\tstd::vector<uint8_t> data;\n \t\tdata.reserve(2);\n-\t\tconst auto &infoMap = controlsInfo.find(&controls::draft::LensShadingMapMode);\n+\t\tconst auto &infoMap = controlsInfo.find(&controls::StatsLensShadingMapMode);\n \t\tif (infoMap != controlsInfo.end()) {\n \t\t\tfor (const auto &value : infoMap->second.values())\n \t\t\t\tdata.push_back(value.get<int32_t>());\ndiff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\nindex 84e843b1..3236da1d 100644\n--- a/src/libcamera/control_ids.yaml\n+++ b/src/libcamera/control_ids.yaml\n@@ -570,6 +570,133 @@ controls:\n             reduction to high-resolution streams, since those will be\n             reprocessed later if necessary.\n \n+  - LensShadingMode:\n+      type: int32_t\n+      description: |\n+        Mode of operation for lens shading correction.\n+\n+        When set to Off, no lens shading correction will be applied by the\n+        camera device, and an identity lens shading map data will be provided\n+        if StatsLensShadingMapMode is On.\n+\n+        When set to other modes, lens shading correction will be applied by the\n+        camera device. The lens shading map data can be requested by\n+        applications by setting StatsLensShadingMapMode to On, and the lens\n+        shading map will be reported in StatsLensShadingMap.\n+        dark conditions.\n+      enum:\n+        - name: LensShadingModeOff\n+          value: 0\n+          description: No lens shading correction is applied.\n+        - name: LensShadingModeFast\n+          value: 1\n+          description: |\n+            Apply lens shading corrections, without slowing frame rate relative\n+            to sensor raw output.\n+        - name: LensShadingModeHighQuality\n+          value: 2\n+          description: |\n+            Apply high-quality lens shading correction, at the cost of possibly\n+            reduced frame rate.\n+\n+  - StatsLensShadingMapMode:\n+      type: int32_t\n+      description: |\n+       Control to instruct the camera device to report the lens shading map.\n+       When set to On, the lens shading map will be provided in\n+       StatsLensShadingMap.\n+\n+       \\sa StatsLensShadingMap\n+      enum:\n+        - name: StatsLensShadingMapModeOff\n+          value: 0\n+          description: Do not include a lens shading map in the capture result.\n+        - name: StatsLensShadingMapModeOn\n+          value: 1\n+          description: Include a lens shading map in the capture result.\n+\n+  - StatsLensShadingMapSize:\n+      type: Size\n+      description: |\n+        Control to report the dimensions of the lens shading correction map,\n+        which is reported in StatsLensShadingMap.\n+\n+        When a lens shading correction map is reported, both this control and\n+        StatsLensShadingMap must be reported together. The exception is if the\n+        lens shading correction map is empty, in which case this control may\n+        report a zero size and StatsLensShadingMap may be omitted.\n+\n+        \\sa StatsLensShadingMap\n+\n+  - StatsLensShadingMap:\n+      type: float\n+      size: [4*n*m]\n+      description: |\n+        Control to report the lens shading correction map. It is a\n+        low-resolution floating-point map that lists the coefficients used to\n+        correct for vignetting, for each Bayer color channel. The size of the\n+        lens shading correction map shall be reported in\n+        StatsLensShadingMapSize.\n+\n+        When a lens shading correction map is reported, both this control and\n+        StatsLensShadingMapSize must be reported together. The exception is if\n+        the lens shading correction map is empty, in which case\n+        StatsLensShadingMapSize may report a zero size and this control may be\n+        omitted.\n+\n+        The shading map is for the entire active pixel array, and is not\n+        affected by the crop region specified in the request. Each shading map\n+        entry is the value of the shading compensation map over a specific\n+        pixel on the sensor. Specifically, with an (NxM) resolution shading\n+        map, and an active pixel array size (WxH), shading map entry (x, y)\n+        from the domain (0 ... N-1, 0 ... M-1) is the value of the shading map\n+        at pixel (((W-1)/(N-1)) * x, ((H-1)/(M-1)) * y) for the four color\n+        channels. The map is assumed to be bilinearly interpolated between the\n+        sample points.\n+\n+        The channel order is [R, Geven, Godd, B], where Geven is the green\n+        channel for the even rows of a Bayer pattern, and Godd is the odd rows.\n+        The shading map is stored in a fully interleaved format.\n+\n+        The shading map will generally have on the order of 30-40 rows and\n+        columns, and will be smaller than 64x64.\n+\n+        As an example, given a very small map defined as follows\n+\n+        width,height = [ 4, 3 ]\n+        values =\n+          [ 1.3, 1.2, 1.15, 1.2,  1.2, 1.2,  1.15, 1.2,\n+            1.1, 1.2, 1.2,  1.2,  1.3, 1.2,  1.3,  1.3,\n+            1.2, 1.2, 1.25, 1.1,  1.1, 1.1,  1.1,  1.0,\n+            1.0, 1.0, 1.0,  1.0,  1.2, 1.3,  1.25, 1.2,\n+            1.3, 1.2, 1.2,  1.3,  1.2, 1.15, 1.1,  1.2,\n+            1.2, 1.1, 1.0,  1.2,  1.3, 1.15, 1.2,  1.3 ]\n+\n+        The low-resolution scaling map images for each channel are as follows\n+\n+        Red lens shading map\n+        [ [ 1.3, 1.2, 1.1, 1.3 ],\n+          [ 1.2, 1.1, 1.0, 1.2 ],\n+          [ 1.3, 1.2, 1.2, 1.3 ] ]\n+\n+        Green (even rows) lens shading map\n+        [ [ 1.2, 1.2, 1.2, 1.2 ],\n+          [ 1.2, 1.1, 1.0, 1.3 ],\n+          [ 1.2, 1.15, 1.1, 1.15 ] ]\n+\n+        Green (odd rows) lens shading map\n+        [ [ 1.15, 1.15, 1.2, 1.3 ],\n+          [ 1.25, 1.1,  1.0, 1.25 ],\n+          [ 1.2,  1.1,  1.0, 1.2 ] ]\n+\n+        Blue lens shading map\n+        [ [ 1.2, 1.2, 1.2, 1.3 ],\n+          [ 1.1, 1.0, 1.0, 1.2 ],\n+          [ 1.3, 1.2, 1.2, 1.3 ] ]\n+\n+        For a monochrome camera, all four color channels must have the same\n+        values.\n+\n   # ----------------------------------------------------------------------------\n   # Draft controls section\n \n@@ -706,20 +833,6 @@ controls:\n        row and the start of exposure of the last row. Currently identical to\n        ANDROID_SENSOR_ROLLING_SHUTTER_SKEW\n \n-  - LensShadingMapMode:\n-      type: int32_t\n-      draft: true\n-      description: |\n-       Control to report if the lens shading map is available. Currently\n-       identical to ANDROID_STATISTICS_LENS_SHADING_MAP_MODE.\n-      enum:\n-        - name: LensShadingMapModeOff\n-          value: 0\n-          description: No lens shading map mode is available.\n-        - name: LensShadingMapModeOn\n-          value: 1\n-          description: The lens shading map mode is available.\n-\n   - SceneFlicker:\n       type: int32_t\n       draft: true\n","prefixes":["libcamera-devel","1/2"]}