From patchwork Fri Jul 3 12:25:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 27174 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 B4B31C328C for ; Fri, 3 Jul 2026 12:26:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D95465FED; Fri, 3 Jul 2026 14:26:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ttfNjBkn"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8856E65FE2 for ; Fri, 3 Jul 2026 14:26:53 +0200 (CEST) Received: from neptunite.hamster-moth.ts.net (unknown [IPv6:2404:7a81:160:2100:a2cc:2f45:3bd7:2589]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AAED68E0; Fri, 3 Jul 2026 14:26:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1783081567; bh=FCiGnoB4Og2o4qyO7umIfuJjmc37YufL40KZPeR89kE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ttfNjBknqTHg0h/C2WNO675WYHhpjQT3qFIhzvr0TVMO/rie7VWUjW//X2gXhkWtf OsgTjG5iP+siuZqhcNSuavKJoopbHQKA+Jsp/Tyc4nsqZPF1IhPV8lu8o8Aam7E4Au TFVs++NxFnucrBcFdtMk9+OzaPxHv4zxxyBlADsU= From: Paul Elder To: laurent.pinchart@ideasonboard.com Cc: Paul Elder , michael.riesch@collabora.com, xuhf@rock-chips.com, stefan.klug@ideasonboard.com, kieran.bingham@ideasonboard.com, dan.scally@ideasonboard.com, jacopo.mondi@ideasonboard.com, nicolas.dufresne@collabora.com, libcamera-devel@lists.libcamera.org Subject: [RFC PATCH 15/19] utils: tuning: libtuning: image: Enable images missing some metadata Date: Fri, 3 Jul 2026 21:25:21 +0900 Message-ID: <20260703122543.1991189-16-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20260703122543.1991189-1-paul.elder@ideasonboard.com> References: <20260703122543.1991189-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 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" Some pipeline handlers, like the rkisp2 pipeline handler, are capable of taking raw images but cannot set: - exposure time - gain - black level yet as they have not been implemented for raw mode yet. Arguably black mode will never be supported in raw mode as it bypasses the ISP completely and black level subtraction is in the ISP. This prevents the images from being used for tuning in the current libtuning-based tuning scripts as it requires exposure time and iso and black level, so modify libtuning to allow images with no exposure time and iso and black level. Signed-off-by: Paul Elder --- utils/tuning/libtuning/image.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/utils/tuning/libtuning/image.py b/utils/tuning/libtuning/image.py index ecd334bdc67f..b1ada0d0867c 100644 --- a/utils/tuning/libtuning/image.py +++ b/utils/tuning/libtuning/image.py @@ -70,12 +70,27 @@ class Image: white = metadata[f'Exif.{subimage}.WhiteLevel'].value self.sigbits = int(white).bit_length() self.fmt = (self.sigbits - 4) // 2 - self.exposure = int(metadata[f'Exif.{photo}.ExposureTime'].value * 1000000) - self.againQ8 = metadata[f'Exif.{photo}.ISOSpeedRatings'].value * 256 / 100 - self.againQ8_norm = self.againQ8 / 256 + + self.exposure = None + exposure_key = f'Exif.{photo}.ExposureTime' + if exposure_key in metadata: + self.exposure = int(metadata[exposure_key].value * 1000000) + + self.againQ8 = None + self.againQ8_norm = None + iso_key = f'Exif.{photo}.ISOSpeedRatings' + if iso_key in metadata: + self.againQ8 = metadata[iso_key].value * 256 / 100 + self.againQ8_norm = self.againQ8 / 256 + + self.blacklevel = 0 + self.blacklevel_16 = 0 + bl_key = f'Exif.{subimage}.BlackLevel' + if bl_key in metadata: + self.blacklevel = int(metadata[bl_key].value[0]) + self.blacklevel_16 = self.blacklevel << (16 - self.sigbits) + self.camName = metadata['Exif.Image.Model'].value - self.blacklevel = int(metadata[f'Exif.{subimage}.BlackLevel'].value[0]) - self.blacklevel_16 = self.blacklevel << (16 - self.sigbits) # Channel order depending on bayer pattern # The key is the order given by exif, where 0 is R, 1 is G, and 2 is B