Patch Detail
Show a patch.
GET /api/1.1/patches/16924/?format=api
{ "id": 16924, "url": "https://patchwork.libcamera.org/api/1.1/patches/16924/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16924/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20220803082539.11172-1-william.vinnicombe@raspberrypi.com>", "date": "2022-08-03T08:25:39", "name": "[libcamera-devel,v3] utils: raspberrypi: ctt: dng_load_image: Work with DNG files from Picamera2", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "ca3a115ebba9027d374a76c96392ef2e99ae1d00", "submitter": { "id": 97, "url": "https://patchwork.libcamera.org/api/1.1/people/97/?format=api", "name": "Nicolas Dufresne via libcamera-devel", "email": "libcamera-devel@lists.libcamera.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16924/mbox/", "series": [ { "id": 3363, "url": "https://patchwork.libcamera.org/api/1.1/series/3363/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3363", "date": "2022-08-03T08:25:39", "name": "[libcamera-devel,v3] utils: raspberrypi: ctt: dng_load_image: Work with DNG files from Picamera2", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3363/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16924/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16924/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 7A37EBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 3 Aug 2022 08:25:59 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E0BD763313;\n\tWed, 3 Aug 2022 10:25:58 +0200 (CEST)", "from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 18EF6603EF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 3 Aug 2022 10:25:57 +0200 (CEST)", "by mail-wm1-x335.google.com with SMTP id\n\t8-20020a05600c024800b003a2fe343db1so519720wmj.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 03 Aug 2022 01:25:57 -0700 (PDT)", "from wv-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tl12-20020a7bc44c000000b003a2e42ae9a4sm1822352wmi.14.2022.08.03.01.25.55\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 03 Aug 2022 01:25:55 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659515158;\n\tbh=Tau/yevSZXKMouDpmlcLQo4QB3F6TTWc3d7WrY3wpx4=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=IVMfjcMVFHxhFX1XI09LeriZixhUMljvJVerSjgA4AQCUk7EWaOYb3yHOISKHJOFh\n\tct+OkLo1b9u8DdAuYFaYQJAF3b9QxupVzWqImaqQ0GzGZFpBfCVYy11CfXZ56kZifP\n\tNWTdyXdduqLTZab0qao3HFye1+Grhdgx+cjzr9LJrSdBLFJdOgBFia7Kliw+cITRyz\n\tCEHAETEEUwc23zv84CL5R3JelicUWjKmoSH7akWnWHciKzOhtpx+7YfuMT/ytTBy6Z\n\t/YcinN1jcZM7cE0ZOADLFQ9tetalhPFfpUQBrIzoB+maXcI5OXirvXnFoqSnyuIn4K\n\tPbUi0RLZgwNZw==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=AGZOioqHnXhWwEKmDTA6/duzrAvvA7O+MuvjuNarU3A=;\n\tb=Mr2B+lPH7CsAm3LIWWP9lbBjizUONIJkxkfeUlxyT1SZLBe3mSInoo9xABWkj/36ep\n\tgzTO3QwHWksYzLqbfBVvEbcTkm6JLEkHOXGsr/QBRQB7bhXDFXHOeCmwO9gYmFQGTl2J\n\tojbu7zm6Z1mPXoiS8qwBLSTgrg5MSF10o+btJcjGuamvqT4rlwgdN5qU+4EbHzymcNxF\n\tzLTABckOcK8/1ZPlXpm4i6zjyhtCR4+Xb01axuV9kxQmmqHEVgFRrlmiLNgLpjajuOzH\n\tOT0XH6mqnYIIs88OWf79kNfdqXZaexghD3mu/d9CRAOyxAIVP7OFjzOVMXA0YsYsEu5a\n\tVOUA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Mr2B+lPH\"; 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:mime-version\n\t:content-transfer-encoding;\n\tbh=AGZOioqHnXhWwEKmDTA6/duzrAvvA7O+MuvjuNarU3A=;\n\tb=hE/f0qb5n7OHWr81X7th1IBB/fV4neVzVr8cTg6lvDv3dRJ8tZ9v6iwGRRQeXYumgU\n\ty0d3QVK57IHT2/MY/5/1T4R4c2IsJBrMn9PXkhSlULPreglIuDHjnPcgEdYXnK0fsORI\n\t0eh0j2mMuU/soEwYiW24LsM/UZMZ1s5GVjIbh2iR5MrJ8jGkxvfKFLfII4EAHlQnphiu\n\tJRw22SEY+klhFkEumSf4k9FTJiF5YGI8lsgRFk2ZUDhWTD7nE0Yn6bvv97jr5ZdPrpUX\n\tgmtR0N/jY6GbNzvoapKIDuUV2oEMbORmyRscGgR3a/qhcXA2jC0Yrq/sjyVvT6NROqRs\n\tle8Q==", "X-Gm-Message-State": "ACgBeo2zJjhSh5gGS2zA6PSvR+vkWjQFgc0XxdhmncTqKO25mKL0fIX7\n\tgCDwAnA1N4VmTweiJEA7O5zH5MOcUClYEw==", "X-Google-Smtp-Source": "AA6agR7xTo4Ri309o/rAKa++Pz4y6T+1ux/WWt+Aw2aRB+am0CMSdDCDZF5Ryyfhu6DiQIaqDfEJQw==", "X-Received": "by 2002:a7b:c3d4:0:b0:3a3:ce7:7894 with SMTP id\n\tt20-20020a7bc3d4000000b003a30ce77894mr2048677wmj.134.1659515156385; \n\tWed, 03 Aug 2022 01:25:56 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 3 Aug 2022 09:25:39 +0100", "Message-Id": "<20220803082539.11172-1-william.vinnicombe@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3] 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", "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 DNG specification is based on the TIFF file format and recommends\nstoring the raw image data in a SubIFD and the Exif tags in an Exif IFD.\nOther options are allowed, even if not recommended, such as storing both\nthe raw image data and the Exif data in IFD0, as done by the TIFF/EP\nspecification.\n\nlibcamera-apps use pyexiv2 to produce DNG files, following the DNG\nrecommendation, while applications based on picamera2 use PiDNG, which\nadopts the TIFF/EP structure. Why it does so is not currently clear (see\nhttps://github.com/schoolpost/PiDNG/issues/65 for discussions on this\ntopic), but as files based on the DNG and TIFF/EP variants exist in the\nwild, both need to be supported by ctt.\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 | 32 +++++++++++++++++++------\n 1 file changed, 25 insertions(+), 7 deletions(-)", "diff": "diff --git a/utils/raspberrypi/ctt/ctt_image_load.py b/utils/raspberrypi/ctt/ctt_image_load.py\nindex 934db123..7f8ba72a 100644\n--- a/utils/raspberrypi/ctt/ctt_image_load.py\n+++ b/utils/raspberrypi/ctt/ctt_image_load.py\n@@ -301,17 +301,35 @@ 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+ The DNG and TIFF/EP specifications use different IFDs to store the raw\n+ image data and the Exif tags. DNG stores them in a SubIFD and in an Exif\n+ IFD respectively (named \"SubImage1\" and \"Photo\" by pyexiv2), while\n+ TIFF/EP stores them both in IFD0 (name \"Image\"). Both are used in \"DNG\"\n+ files, with libcamera-apps following the DNG recommendation and\n+ applications based on picamera2 following TIFF/EP.\n+\n+ This code detects which tags are being used, and therefore extracts the\n+ 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 +337,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", "v3" ] }