From patchwork Fri Jun 28 10:47:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20482 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 E68C2BD87C for ; Fri, 28 Jun 2024 10:49:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A12B463367; Fri, 28 Jun 2024 12:49:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VKMN0pdQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BC7B663362 for ; Fri, 28 Jun 2024 12:49:44 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:82ab:924:d918:cd24]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 405DA735; Fri, 28 Jun 2024 12:49:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719571760; bh=TEeO5DWfj3x/4A/L879TfnOp/7D0yqa8qPAlDF9A3AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VKMN0pdQr3UVTBV8mnvnCHTGIFDD8NK1NZkGC1snFlKkwSurqDTorGP2Z1Y78vpEX 4dr3dc0wDxKyn+FSEkaoiNyV6b3m7XVk3mdShSNTlLldFtNyw2eyrOVm76UZ5788Sn CoVXurmsm90ByY2KhmTnJrJfo8iUxLoL88ztcJ/o= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 23/25] libtuning: Make blacklevel optional Date: Fri, 28 Jun 2024 12:47:16 +0200 Message-ID: <20240628104828.2928109-24-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628104828.2928109-1-stefan.klug@ideasonboard.com> References: <20240628104828.2928109-1-stefan.klug@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" Not every sensor provides blacklevel information through the kernel interface. We should therefore not require that information to be in the raw images for the tuning process. It can be provided via the tuning config. Signed-off-by: Stefan Klug --- utils/tuning/libtuning/image.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/utils/tuning/libtuning/image.py b/utils/tuning/libtuning/image.py index c8911a0ff125..0b9c78fcd9c2 100644 --- a/utils/tuning/libtuning/image.py +++ b/utils/tuning/libtuning/image.py @@ -25,6 +25,8 @@ class Image: self.color = -1 self.lux = -1 self.macbeth = None + self.blacklevel = 0 + self.blacklevel_16 = 0 try: self._load_metadata_exif() @@ -74,8 +76,12 @@ class Image: self.againQ8 = metadata[f'Exif.{photo}.ISOSpeedRatings'].value * 256 / 100 self.againQ8_norm = self.againQ8 / 256 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) + if f'Exif.{subimage}.BlackLevel' in metadata: + self.blacklevel = int(metadata[f'Exif.{subimage}.BlackLevel'].value[0]) + self.blacklevel_16 = self.blacklevel << (16 - self.sigbits) + else: + logger.warning("Image doesn't contain blacklevel info") + # 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