{"id":11907,"url":"https://patchwork.libcamera.org/api/1.1/patches/11907/?format=json","web_url":"https://patchwork.libcamera.org/patch/11907/","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":"<20210413101439.14659-4-jacopo@jmondi.org>","date":"2021-04-13T10:14:39","name":"[libcamera-devel,v5,3/3] android: camera_device: Report sensor physical size","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"3ef55ec8ef4d451c667af977969677f3281c3e12","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/1.1/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/11907/mbox/","series":[{"id":1917,"url":"https://patchwork.libcamera.org/api/1.1/series/1917/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1917","date":"2021-04-13T10:14:36","name":"Introduce sensor database","version":5,"mbox":"https://patchwork.libcamera.org/series/1917/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11907/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11907/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 A3145BD224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Apr 2021 10:14:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A11556880B;\n\tTue, 13 Apr 2021 12:14:09 +0200 (CEST)","from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5AFD4687FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Apr 2021 12:14:08 +0200 (CEST)","from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 6546224000F;\n\tTue, 13 Apr 2021 10:14:07 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 13 Apr 2021 12:14:39 +0200","Message-Id":"<20210413101439.14659-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210413101439.14659-1-jacopo@jmondi.org>","References":"<20210413101439.14659-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v5 3/3] android: camera_device: Report\n\tsensor physical size","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>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Calculate the value of the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property\nmultiplying the number of sensor's readable pixels with the pixel unit\ncell size if provided by the Camera.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 30 ++++++++++++++++--------------\n 1 file changed, 16 insertions(+), 14 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 89044efa7ebe..754ee00af472 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -9,6 +9,7 @@\n #include \"camera_ops.h\"\n #include \"post_processor.h\"\n \n+#include <array>\n #include <cmath>\n #include <fstream>\n #include <sys/mman.h>\n@@ -1026,15 +1027,23 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1);\n \n \t/* Sensor static metadata. */\n+\tstd::array<int32_t, 2> pixelArraySize;\n \t{\n-\t\tconst Size &size =\n-\t\t\tproperties.get(properties::PixelArraySize);\n-\t\tstd::vector<int32_t> data{\n-\t\t\tstatic_cast<int32_t>(size.width),\n-\t\t\tstatic_cast<int32_t>(size.height),\n-\t\t};\n+\t\tconst Size &size = properties.get(properties::PixelArraySize);\n+\t\tpixelArraySize[0] = size.width;\n+\t\tpixelArraySize[1] = size.height;\n \t\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,\n-\t\t\t\t\t  data.data(), data.size());\n+\t\t\t\t\t  pixelArraySize.data(), pixelArraySize.size());\n+\t}\n+\n+\tif (properties.contains(properties::UnitCellSize)) {\n+\t\tconst Size &cellSize = properties.get<Size>(properties::UnitCellSize);\n+\t\tstd::array<float, 2> physicalSize{\n+\t\t\tcellSize.width * pixelArraySize[0] / 1e6f,\n+\t\t\tcellSize.height * pixelArraySize[1] / 1e6f\n+\t\t};\n+\t\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE,\n+\t\t\t\t\t  physicalSize.data(), physicalSize.size());\n \t}\n \n \t{\n@@ -1082,13 +1091,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t\t\t\t  testPatterModes.data(),\n \t\t\t\t  testPatterModes.size());\n \n-\tstd::vector<float> physicalSize = {\n-\t\t2592, 1944,\n-\t};\n-\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE,\n-\t\t\t\t  physicalSize.data(),\n-\t\t\t\t  physicalSize.size());\n-\n \tuint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN;\n \tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,\n \t\t\t\t  &timestampSource, 1);\n","prefixes":["libcamera-devel","v5","3/3"]}