From patchwork Tue Dec 21 05:25:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 15199 X-Patchwork-Delegate: paul.elder@ideasonboard.com 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 70ED7C3258 for ; Tue, 21 Dec 2021 05:25:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EFF35608F9; Tue, 21 Dec 2021 06:25:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YM1CUrmZ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 50387608E9 for ; Tue, 21 Dec 2021 06:25:21 +0100 (CET) Received: from pyrite.mediacom.info (unknown [IPv6:2604:2d80:ad90:fb00:96fd:8874:873:6c16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69FBFFD2; Tue, 21 Dec 2021 06:25:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1640064321; bh=9X06w33Dsa53G7mcjN4zL3DuXJBAYf7W+ICSjP/7sIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YM1CUrmZKKu1cRcavoxA1xBwvfaySduy6WbUfqVPOPvAP7hKoZYgvrpUDJdt9k3ST 47T8SoRDTGF/+4MXiesLQlnn0MmoxQqRO8oMuhIq/OIxfAi3QeyVNgptOEDwB2mVxC z+CPNA0lPkS0h8NuWR/Dra+576f8Yf7HxoikKRHk= From: Paul Elder 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 Subject: [libcamera-devel] [PATCH 1/2] controls: Add controls for lens shading maps 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" Add controls related to lens shading maps: - For requesting the lens shading map to be reported - For reporting the lens shading map - For requesting that lens shading be applied, and to what degree Previously only the first was available, as a draft control. Promote it to non-draft, upgrade the description, and add the other two. Signed-off-by: Paul Elder --- src/android/camera_capabilities.cpp | 2 +- src/libcamera/control_ids.yaml | 141 +++++++++++++++++++++++++--- 2 files changed, 128 insertions(+), 15 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index c716f4bf..742c6a6a 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1364,7 +1364,7 @@ int CameraCapabilities::initializeStaticMetadata() { std::vector data; data.reserve(2); - const auto &infoMap = controlsInfo.find(&controls::draft::LensShadingMapMode); + const auto &infoMap = controlsInfo.find(&controls::StatsLensShadingMapMode); if (infoMap != controlsInfo.end()) { for (const auto &value : infoMap->second.values()) data.push_back(value.get()); diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 84e843b1..3236da1d 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -570,6 +570,133 @@ controls: reduction to high-resolution streams, since those will be reprocessed later if necessary. + - LensShadingMode: + type: int32_t + description: | + Mode of operation for lens shading correction. + + When set to Off, no lens shading correction will be applied by the + camera device, and an identity lens shading map data will be provided + if StatsLensShadingMapMode is On. + + When set to other modes, lens shading correction will be applied by the + camera device. The lens shading map data can be requested by + applications by setting StatsLensShadingMapMode to On, and the lens + shading map will be reported in StatsLensShadingMap. + dark conditions. + enum: + - name: LensShadingModeOff + value: 0 + description: No lens shading correction is applied. + - name: LensShadingModeFast + value: 1 + description: | + Apply lens shading corrections, without slowing frame rate relative + to sensor raw output. + - name: LensShadingModeHighQuality + value: 2 + description: | + Apply high-quality lens shading correction, at the cost of possibly + reduced frame rate. + + - StatsLensShadingMapMode: + type: int32_t + description: | + Control to instruct the camera device to report the lens shading map. + When set to On, the lens shading map will be provided in + StatsLensShadingMap. + + \sa StatsLensShadingMap + enum: + - name: StatsLensShadingMapModeOff + value: 0 + description: Do not include a lens shading map in the capture result. + - name: StatsLensShadingMapModeOn + value: 1 + description: Include a lens shading map in the capture result. + + - StatsLensShadingMapSize: + type: Size + description: | + Control to report the dimensions of the lens shading correction map, + which is reported in StatsLensShadingMap. + + When a lens shading correction map is reported, both this control and + StatsLensShadingMap must be reported together. The exception is if the + lens shading correction map is empty, in which case this control may + report a zero size and StatsLensShadingMap may be omitted. + + \sa StatsLensShadingMap + + - StatsLensShadingMap: + type: float + size: [4*n*m] + description: | + Control to report the lens shading correction map. It is a + low-resolution floating-point map that lists the coefficients used to + correct for vignetting, for each Bayer color channel. The size of the + lens shading correction map shall be reported in + StatsLensShadingMapSize. + + When a lens shading correction map is reported, both this control and + StatsLensShadingMapSize must be reported together. The exception is if + the lens shading correction map is empty, in which case + StatsLensShadingMapSize may report a zero size and this control may be + omitted. + + The shading map is for the entire active pixel array, and is not + affected by the crop region specified in the request. Each shading map + entry is the value of the shading compensation map over a specific + pixel on the sensor. Specifically, with an (NxM) resolution shading + map, and an active pixel array size (WxH), shading map entry (x, y) + from the domain (0 ... N-1, 0 ... M-1) is the value of the shading map + at pixel (((W-1)/(N-1)) * x, ((H-1)/(M-1)) * y) for the four color + channels. The map is assumed to be bilinearly interpolated between the + sample points. + + The channel order is [R, Geven, Godd, B], where Geven is the green + channel for the even rows of a Bayer pattern, and Godd is the odd rows. + The shading map is stored in a fully interleaved format. + + The shading map will generally have on the order of 30-40 rows and + columns, and will be smaller than 64x64. + + As an example, given a very small map defined as follows + + width,height = [ 4, 3 ] + values = + [ 1.3, 1.2, 1.15, 1.2, 1.2, 1.2, 1.15, 1.2, + 1.1, 1.2, 1.2, 1.2, 1.3, 1.2, 1.3, 1.3, + 1.2, 1.2, 1.25, 1.1, 1.1, 1.1, 1.1, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.2, 1.3, 1.25, 1.2, + 1.3, 1.2, 1.2, 1.3, 1.2, 1.15, 1.1, 1.2, + 1.2, 1.1, 1.0, 1.2, 1.3, 1.15, 1.2, 1.3 ] + + The low-resolution scaling map images for each channel are as follows + + Red lens shading map + [ [ 1.3, 1.2, 1.1, 1.3 ], + [ 1.2, 1.1, 1.0, 1.2 ], + [ 1.3, 1.2, 1.2, 1.3 ] ] + + Green (even rows) lens shading map + [ [ 1.2, 1.2, 1.2, 1.2 ], + [ 1.2, 1.1, 1.0, 1.3 ], + [ 1.2, 1.15, 1.1, 1.15 ] ] + + Green (odd rows) lens shading map + [ [ 1.15, 1.15, 1.2, 1.3 ], + [ 1.25, 1.1, 1.0, 1.25 ], + [ 1.2, 1.1, 1.0, 1.2 ] ] + + Blue lens shading map + [ [ 1.2, 1.2, 1.2, 1.3 ], + [ 1.1, 1.0, 1.0, 1.2 ], + [ 1.3, 1.2, 1.2, 1.3 ] ] + + For a monochrome camera, all four color channels must have the same + values. + # ---------------------------------------------------------------------------- # Draft controls section @@ -706,20 +833,6 @@ controls: row and the start of exposure of the last row. Currently identical to ANDROID_SENSOR_ROLLING_SHUTTER_SKEW - - LensShadingMapMode: - type: int32_t - draft: true - description: | - Control to report if the lens shading map is available. Currently - identical to ANDROID_STATISTICS_LENS_SHADING_MAP_MODE. - enum: - - name: LensShadingMapModeOff - value: 0 - description: No lens shading map mode is available. - - name: LensShadingMapModeOn - value: 1 - description: The lens shading map mode is available. - - SceneFlicker: type: int32_t draft: true