{"id":16583,"url":"https://patchwork.libcamera.org/api/1.1/patches/16583/?format=json","web_url":"https://patchwork.libcamera.org/patch/16583/","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":"<20220711102628.14269-3-william.vinnicombe@raspberrypi.com>","date":"2022-07-11T10:26:28","name":"[libcamera-devel,v2,2/2] utils: raspberrypi: ctt: dng_load_image: Work with DNG files from Picamera2","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"394077557b4767b336f1306906c97e1734133ea1","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/1.1/people/97/?format=json","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16583/mbox/","series":[{"id":3268,"url":"https://patchwork.libcamera.org/api/1.1/series/3268/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3268","date":"2022-07-11T10:26:26","name":"Raspberry Pi tuning tool improvements","version":2,"mbox":"https://patchwork.libcamera.org/series/3268/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16583/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16583/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 AE270BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Jul 2022 10:31:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 181FD63318;\n\tMon, 11 Jul 2022 12:31:31 +0200 (CEST)","from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D951560401\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Jul 2022 12:26:41 +0200 (CEST)","by mail-wm1-x333.google.com with SMTP id\n\t9-20020a1c0209000000b003a2dfdebe47so1940853wmc.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Jul 2022 03:26:41 -0700 (PDT)","from wv-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tp12-20020a7bcc8c000000b0039749b01ea7sm8138000wma.32.2022.07.11.03.26.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 11 Jul 2022 03:26:41 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657535491;\n\tbh=ocygqkGskawhmMCslSR4PzBIKQE9Oq6OvUlzCoNQc7Q=;\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:Cc:\n\tFrom;\n\tb=Wd/FT69kvYsqLkHzazULLYBdNLae+se3vvHxkzvim0ac0PLip62msuGQ7hou6LVxg\n\tdHhCpsdFuZXRSdE6USj6pPzzv4wclv6Xu/Z+pp9lKPjuTMx79+ilG+KTvPLhnsv835\n\tKKLWLRhU/VBqFm7VIyCg7beaPjkLHPRoKRYdlUQ22zgdNw8S9sLqaqLxRsqYspEJQA\n\t/NXjNG9I0r7I/Fidkw5tk2mfmwIDYyfqTYhLmbCPTTLI3ilEH/7wH1KGe5JdnRWo56\n\thhdEg9L/O6a0rfFJt33nsGNkJBUYItDROKQmY0CNkJTm1eR4l1q5sdFB5zwde/l0nO\n\tV3xW09WjTR8rg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=IkpjAqUiQOxnAPFYlVvU5FcwtfCnYVkOCEuXbvSUyCA=;\n\tb=Z7MrJatA+wOohz/yqpne0xKGHsHGdG5hR/HnFlQ8jsOWpdeNTVD3N0UyRS4T7br5jL\n\t2UmTVPYJ3SO4DbdxT/Bz3t9flKPJgqAm1zTbt6C7roZV58s2C28pBvkkLD0T6JZYPoLs\n\tCyKRf6pxuKeGjPVvCw5wc30sCE4OVRCHkfndwFWqe9zSHcGsaePdA6gy0Q+4VkjKUWYS\n\tUU7hd2/b1xG8qstvpKguC24dhIwGeG+XhgG4GGlvfSAP+HSQGOmXlMzgz8XYHKoIB0Aw\n\tNdnb5WnMHmDPKXzHs4hB+VZzRU5vo0CySUwGVAd1i9ZpCIQoE140LwWBtSpiaRa+QlB1\n\td1Qw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Z7MrJatA\"; 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:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=IkpjAqUiQOxnAPFYlVvU5FcwtfCnYVkOCEuXbvSUyCA=;\n\tb=6f2UEP3kvaM66HYMpMAF/DGEd6C4LzYF1cLRzYwlq1lwno9stglAhNpc+JxoMokiZ5\n\t+Hr0ZdCKbI6c0W3KgMq4Yy3zAYxXS3QzczlDOohEJx09LN8lVjq4bCae3vjRr0GlfAc/\n\tsnUYOyxJDUIdvdbneEG9FDsB0iZdRhTS6Kl/Uej1/EdVev6h4p5mKfSWFCMxdhrZOE6O\n\trWOzZBjCq6tMfMegmCrwDljwwlczFGFsvpW/VTvB5x+PhAkgveFihtAxyENEGCIszLu0\n\tmhyQ8VaLW/J9x9N/kMniSFwgYzZLW8CltMtEYQE7bcReGpX//E5JJTPgpv9SrOX5mcvL\n\t4CXw==","X-Gm-Message-State":"AJIora/yrUGljmXlb9elMWLDlXVeVa7daCfZ9BjdR1qzNafvXmQqamc/\n\t7BjzAUXTTOVMVcM8Cs4V8kIrkgUIV4E+tA==","X-Google-Smtp-Source":"AGRyM1tzMbQ9KBoWwHccEo/5Iwrk1mn9f3D+pwdNF340PE9m+6fTSXS9yWTaKOzmZ+wnH2SbiWxSYQ==","X-Received":"by 2002:a05:600c:4f54:b0:3a0:4a5b:2692 with SMTP id\n\tm20-20020a05600c4f5400b003a04a5b2692mr15443582wmq.109.1657535201455; \n\tMon, 11 Jul 2022 03:26:41 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 11 Jul 2022 11:26:28 +0100","Message-Id":"<20220711102628.14269-3-william.vinnicombe@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220711102628.14269-1-william.vinnicombe@raspberrypi.com>","References":"<20220711102628.14269-1-william.vinnicombe@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Mailman-Approved-At":"Mon, 11 Jul 2022 12:31:27 +0200","Subject":"[libcamera-devel] [PATCH v2 2/2] 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":"\"william.vinnicombe--- via libcamera-devel\"\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"william.vinnicombe@raspberrypi.com","Cc":"William Vinnicombe <william.vinnicombe@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>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@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","v2","2/2"]}