{"id":16564,"url":"https://patchwork.libcamera.org/api/1.1/patches/16564/?format=json","web_url":"https://patchwork.libcamera.org/patch/16564/","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":"<20220706101836.20153-4-david.plowman@raspberrypi.com>","date":"2022-07-06T10:18:36","name":"[libcamera-devel,3/3] utils: raspberrypi: ctt: dng_load_image: Work with DNG files from Picamera2","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"394077557b4767b336f1306906c97e1734133ea1","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16564/mbox/","series":[{"id":3261,"url":"https://patchwork.libcamera.org/api/1.1/series/3261/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3261","date":"2022-07-06T10:18:33","name":"Raspberry Pi tuning tool improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/3261/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16564/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16564/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 DC28FC3274\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Jul 2022 10:18:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0349A6330C;\n\tWed,  6 Jul 2022 12:18:46 +0200 (CEST)","from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n\t[IPv6:2a00:1450:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 368976330C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Jul 2022 12:18:43 +0200 (CEST)","by mail-wr1-x430.google.com with SMTP id s1so21355145wra.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 06 Jul 2022 03:18:43 -0700 (PDT)","from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:e4a2:3070:eea4:e434])\n\tby smtp.gmail.com with ESMTPSA id\n\ti1-20020adffc01000000b0021b5861eaf7sm35950820wrr.3.2022.07.06.03.18.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 06 Jul 2022 03:18:42 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657102726;\n\tbh=RQ8wvOavvrjqraqVzxUjFxKxPzWH7QDhqyNY3EjH6MA=;\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=fj069aNg2nMYIIR5nTuhr9lfK97peL7m3r3Eg/U0AJU1I+KBxrM83E+yd5jCT1jcr\n\tRXJx9Qkke44UHpYPbH0WHwkejORw2SEocEAVOLmDs4n22YtBUf+o/iLiSVXAcZcRMn\n\tHoGhSTQE01xULI98IGYZ7r2zzREufuEQsEn92g9fumrD2xyBirjXNpHpXLrxtPODAW\n\t2wsg6udvghfZHkE+77pk7byPLfCtgnUhaQxfFcgpY6Ds0lbDO7Ho3FVrv9Jef14qXj\n\t3YZ1L/hySCtlUmV0TB/MtMDSRXSVhWC4vb3vvfX7kZAUmCrWuc9L4xw0NjaP+EXES2\n\tBvuV1mjybD9cg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:subject:date:message-id:in-reply-to:references:mime-version\n\t:content-transfer-encoding;\n\tbh=ssYnUC4vEKEUNpb7OK9FxfyCRxXfp/cJaoAdu/dquFw=;\n\tb=hCkXx4zub2f7GzjVONoU/A5Gtum6uHBQ1ANdmW41l7PBpyxTSqJNmEqlU77NWmASuf\n\tB/7C1lWAMCYXObDkBn066RuXlPaJUZSm3A8Zjbu72qTYVgZfiiogpdvIT8HafrH1oktP\n\tf3gYxy1POGCWU0lbY0RqOtHPLfQbenDPopuBbz5mpnDUNuI8C8uL+HrmKXUJpGr4E6AN\n\tP2nj+cQt79Gs/X7IXwWmNSCRKvI0wUN9G/Hu9v3JLkyFOLAW0hoQ4+XapvLi5sFW+XBU\n\t/dyIPp7UQXrrrTLWMezprF5eGsXrOW4+WeOTB7WhbZAeSYxroyW8I1cBEZAfJaMa0jU7\n\tWvxw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"hCkXx4zu\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=ssYnUC4vEKEUNpb7OK9FxfyCRxXfp/cJaoAdu/dquFw=;\n\tb=lxCryYcLx0J9mwRFw6JacpMZBc6CTouFo+mHrqJ0n86zdNTAgHoyzNlW74jqEAFl18\n\tZPfthDtt+LXhuzDPPpPNP9sQ1cP4Ktpbhs5m9EltVwRrs2FAcADoGeiBmMrgbZow97IR\n\tKdNMz0rz38D2vQLtnmOTTd1b2usqN4TYnd/husPTDeqDNYMneIhHDm0g8RY289TmaFrE\n\tYvfTw+cD+YdMQN2vqvQBAhWT+IH4FOC1cyEC7NET/qF8/uMdDWToLInZAh+xExnzGXQ5\n\tWSQP12zfnR8JnbEPqNHhfhP3SIqfO7W73qmcu05+mcdavEmz+WPkP62NyVj+3znVFC/H\n\tYRUQ==","X-Gm-Message-State":"AJIora9M5LvWUiCUFFJnWy80Wxp0sjonCs/mb3g00X9z/JqDUFCMjVz/\n\tORfhO4e/sZj2hkRfjKicrRBPLMRDKF1h1A==","X-Google-Smtp-Source":"AGRyM1tUGfhU8gYKD0BA+MMX1cb7dNTaznpyeEflgI32ClYM6gH+pZD2aP3Pi4+jIvAhBvLk9RhXMQ==","X-Received":"by 2002:adf:f345:0:b0:21d:6a26:6d8f with SMTP id\n\te5-20020adff345000000b0021d6a266d8fmr15208313wrp.538.1657102722645; \n\tWed, 06 Jul 2022 03:18:42 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org, william.vinnicombe@raspberrypi.com","Date":"Wed,  6 Jul 2022 11:18:36 +0100","Message-Id":"<20220706101836.20153-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20220706101836.20153-1-david.plowman@raspberrypi.com>","References":"<20220706101836.20153-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/3] utils: raspberrypi: ctt:\n\tdng_load_image: Work with DNG files from Picamera2","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":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n\nThe exif tags are different between raw files from libcamera-apps and\nfrom Picamera2, causing issues loading data.\n\nAdd code to identify which tags are being used, and then load the\nmetadata from the correct tags.\n\nSigned-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n---\n utils/raspberrypi/ctt/ctt_image_load.py | 26 ++++++++++++++++++-------\n 1 file changed, 19 insertions(+), 7 deletions(-)","diff":"diff --git a/utils/raspberrypi/ctt/ctt_image_load.py b/utils/raspberrypi/ctt/ctt_image_load.py\nindex 934db123..29c17581 100644\n--- a/utils/raspberrypi/ctt/ctt_image_load.py\n+++ b/utils/raspberrypi/ctt/ctt_image_load.py\n@@ -301,17 +301,29 @@ def dng_load_image(Cam, im_str):\n         metadata.read()\n \n         Img.ver = 100  # random value\n-        Img.w = metadata['Exif.SubImage1.ImageWidth'].value\n+        \"\"\"\n+        libcamera-apps create a separate Exif.Subimage1 for the picture\n+        picamera2 stores everything under Exif.Image\n+        this code detects which one is being used, and therefore extracts the correct values\n+        \"\"\"\n+        try:\n+            Img.w = metadata['Exif.SubImage1.ImageWidth'].value\n+            subimage = \"SubImage1\"\n+            photo = \"Photo\"\n+        except KeyError:\n+            Img.w = metadata['Exif.Image.ImageWidth'].value\n+            subimage = \"Image\"\n+            photo = \"Image\"\n         Img.pad = 0\n-        Img.h = metadata['Exif.SubImage1.ImageLength'].value\n-        white = metadata['Exif.SubImage1.WhiteLevel'].value\n+        Img.h = metadata[f'Exif.{subimage}.ImageLength'].value\n+        white = metadata[f'Exif.{subimage}.WhiteLevel'].value\n         Img.sigbits = int(white).bit_length()\n         Img.fmt = (Img.sigbits - 4) // 2\n-        Img.exposure = int(metadata['Exif.Photo.ExposureTime'].value*1000000)\n-        Img.againQ8 = metadata['Exif.Photo.ISOSpeedRatings'].value*256/100\n+        Img.exposure = int(metadata[f'Exif.{photo}.ExposureTime'].value*1000000)\n+        Img.againQ8 = metadata[f'Exif.{photo}.ISOSpeedRatings'].value*256/100\n         Img.againQ8_norm = Img.againQ8 / 256\n         Img.camName = metadata['Exif.Image.Model'].value\n-        Img.blacklevel = int(metadata['Exif.SubImage1.BlackLevel'].value[0])\n+        Img.blacklevel = int(metadata[f'Exif.{subimage}.BlackLevel'].value[0])\n         Img.blacklevel_16 = Img.blacklevel << (16 - Img.sigbits)\n         bayer_case = {\n             '0 1 1 2': (0, (0, 1, 2, 3)),\n@@ -319,7 +331,7 @@ def dng_load_image(Cam, im_str):\n             '2 1 1 0': (2, (3, 2, 1, 0)),\n             '1 0 2 1': (3, (1, 0, 3, 2))\n         }\n-        cfa_pattern = metadata['Exif.SubImage1.CFAPattern'].value\n+        cfa_pattern = metadata[f'Exif.{subimage}.CFAPattern'].value\n         Img.pattern = bayer_case[cfa_pattern][0]\n         Img.order = bayer_case[cfa_pattern][1]\n \n","prefixes":["libcamera-devel","3/3"]}