{"id":18547,"url":"https://patchwork.libcamera.org/api/1.1/patches/18547/?format=json","web_url":"https://patchwork.libcamera.org/patch/18547/","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":"<CAMAFT9Utd9QxTma=_bMu1DkzHoS-J39H9rQcJ01oOVwcyg+cyA@mail.gmail.com>","date":"2023-04-25T02:04:22","name":"[libcamera-devel] Suboptimal resolution for digital zoom (controls::ScalerCrop)","commit_ref":null,"pull_url":null,"state":"rfc","archived":false,"hash":"a75c2e3bc3bfd7f18eda40e62360b6e9ba660dbc","submitter":{"id":159,"url":"https://patchwork.libcamera.org/api/1.1/people/159/?format=json","name":"Elias Naur","email":"mail@eliasnaur.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18547/mbox/","series":[{"id":3846,"url":"https://patchwork.libcamera.org/api/1.1/series/3846/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3846","date":"2023-04-25T02:04:22","name":"[libcamera-devel] Suboptimal resolution for digital zoom (controls::ScalerCrop)","version":1,"mbox":"https://patchwork.libcamera.org/series/3846/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18547/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18547/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 90B50C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Apr 2023 02:04:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A57DB627DF;\n\tTue, 25 Apr 2023 04:04:36 +0200 (CEST)","from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com\n\t[IPv6:2607:f8b0:4864:20::82d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5848B627CD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Apr 2023 04:04:34 +0200 (CEST)","by mail-qt1-x82d.google.com with SMTP id\n\td75a77b69052e-3ef34e948b1so24967061cf.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Apr 2023 19:04:34 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1682388276;\n\tbh=vh7bJtuFR+L5SCKvv61oS0a1V8Ci4Y16TnGwBORPWP4=;\n\th=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=Knq4aC1c2cs09fQXQ1kVQVLCTx+hk4oRFSREgwmqjoEhjY4Hu8MWE3OJKZxjQv930\n\tdRLwkzzHnfDOH6CHTzdP4cD8ccDnqGvECD6dtbBhp2/HQhIQFgrayYAoJ0OW3b3Hy2\n\t1f3Ijl/Nv9/ujh+bwqjCu/LPHOjGNIitGMiceafmCIoi7FUbRQZwVWePjEOXDegDkd\n\t8D8SWH4NxUb9J3u/NfmOD7BWbbvOZsIkKSz58EE/2+p9cNllwRiucwm/sQB302g9Se\n\tkpwpiWWHvcLgmnN5XtFYECEeM8AqqUjpMAKji/jCjQmVV6kkLEE4nvhnSW4S7ttg2B\n\tuvfnk9jFS8zTw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=eliasnaur.com; s=google; t=1682388273; x=1684980273;\n\th=to:subject:message-id:date:from:mime-version:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=xJ64r6InKXAeawxbufiD/g2pk1DhrPgFioB7AtJhySA=;\n\tb=sdcoOp+UF/AAnxa8Ndav8HlFWHL3IdmbD31JPUYJZ8Qbau5Rki3QBp2ds2kRU8haSI\n\tw4LK2KsP/00d8m0TpnrN70VBAd+W8DgtqsGecuwEwBe458ZMALX3/3EuwyDZCmHAWAYq\n\tyl1O0/2khBEy0aYifarJ6zGO58NWHaEZEYEfNEyGVz68xW4by69p8BLVziHACA7VJ5GJ\n\txhgbeVNse+K8tSGnRGx+11Ye/Y/sM63tEHvZVuCSfvDLgFyueSnEElX1j4v/pubogVyT\n\t8HdXQSbGpKdNoxC18hlalIv4Lk4Jx+42gpkp0VO+lKYVnUpubUDHDI1tstZIMXi4S7bV\n\t/y0w=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=eliasnaur.com\n\theader.i=@eliasnaur.com\n\theader.b=\"sdcoOp+U\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1682388273; x=1684980273;\n\th=to:subject:message-id:date:from:mime-version:x-gm-message-state\n\t:from:to:cc:subject:date:message-id:reply-to;\n\tbh=xJ64r6InKXAeawxbufiD/g2pk1DhrPgFioB7AtJhySA=;\n\tb=E7ONBJEn1n+4iP7MSOs/GXIptDDs/sQbhKWj2vNffjAZxqEzHQi2FwfEa+4LLR/icc\n\t/gT+TuNeDjr6XmX9G8MhuTaI5yPicGEZDs2XUCGR8LvOaA/7rMiPBUyXe09KbCvLUdK2\n\tRlOW4VV0TojkCiFUKhvv0zaLzrPUh/4da/o9819T1pol6fDElpq+DC8/H4p2vR9TNpIk\n\ttIze+rpdl6cWkX5cGwYXUSBKuQxNeXbRbW9hO9Olmr6bdTbusrvwicjfY7dJFDgqF/wZ\n\tCFVuBuCOR+LTDvyMebg0eLuyMrt4fxVljEOgF2WdYAYBBWsAZFJEho44NEU9a3KEVCbD\n\t65jQ==","X-Gm-Message-State":"AAQBX9fjkDqzRtO4CQ6XIFjuRGD9ZDqDqR6vguRxtctE++i98CAX4kA8\n\tuN8aG9uid7JGtQ6sTLZ1ZGS9r92hW8raj1V1oLgk0CBfyyasjym8lxQ=","X-Google-Smtp-Source":"AKy350YTG1Aq2Gubix2sVzs6/UBC54xPRt+pBmmO9QxANuOHoLWcHyOT1sCh0yN9uQxTiVcw5TjJH7Cky4GxsWDYaUA=","X-Received":"by 2002:a05:622a:64a:b0:3e6:59c2:cbae with SMTP id\n\ta10-20020a05622a064a00b003e659c2cbaemr26793421qtb.34.1682388272795;\n\tMon, 24 Apr 2023 19:04:32 -0700 (PDT)","MIME-Version":"1.0","Date":"Mon, 24 Apr 2023 20:04:22 -0600","Message-ID":"<CAMAFT9Utd9QxTma=_bMu1DkzHoS-J39H9rQcJ01oOVwcyg+cyA@mail.gmail.com>","To":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"[libcamera-devel] Suboptimal resolution for digital zoom\n\t(controls::ScalerCrop)","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":"Elias Naur via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Elias Naur <mail@eliasnaur.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Hi,\n\nI'd like to squeeze out as much resolution as possible from my\nRaspberry Pi camera v1\nfor scanning QR codes. The camera  has a fixed focus at ~50cm from the\nlens, so the\nresolution gain from moving the QR codes closer is lost to blur from\nthe loss of focus.\n\nMy current strategy is to scan codes at a distance, but use the\nconsiderable resolution\nof the sensor (~2500x1900) to gain enough resolution for successful scans.\n\nHowever, I fail to find any way to achieve that with libcamera. I\ntried three options, all\nsuboptimal:\n\n1. Configure the camera for full resolution and crop to a smaller\nsection in my program.\nThat works surprisingly well, except that the white-balance etc.\nalgorithms run on the full\nimage and not just the cropped part.\n2. Configure the camera for full resolution and set\ncontrols::ScalerCrop to the area\nof interest. This seems to fix the white-balance algorithms, but\nresults in the cropped\narea being *upscaled* to full resolution when I receive them. Scanning\nfor QR codes\nat full resolution is way too slow on a RPi Zero.\n3. Configure the camera for the same resolution of the area of interest, and set\ncontrols::ScalerCrop. This is efficient, but the sensor is configured\nfor the low\nresolution and thus ruins the resolution gain.\n\nQuestions:\n1. Is there another way?\n2. The following hack works for me,\n\nfindBestFormat(data->sensorFormats_, Size{2592,1944}, bitDepth);\n        const RPiCameraConfiguration *rpiConfig = static_cast<const\nRPiCameraConfiguration *>(config);\n        ret = data->sensor_->setFormat(&sensorFormat,\nrpiConfig->combinedTransform_);\n        if (ret)\n\nWould a similar change that *always* uses the full sensor resolution\nbe acceptable?\nI can't discern any performance issues between full resolution and\nlower resolution.\n\n3. If the above fix is unacceptable, what is the right way to fix this\nissue in libcamera?\n\nThanks,\nElias","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nb/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 00600441..6ed81dc1 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -842,7 +842,7 @@ int PipelineHandlerRPi::configure(Camera *camera,\nCameraConfiguration *config)\n         * request, and apply it to the sensor with the cached transform, if\n         * any.\n         */\n-       V4L2SubdeviceFormat sensorFormat =\nfindBestFormat(data->sensorFormats_, rawStream ? sensorSize : maxSize,\nbitDepth);\n+       V4L2SubdeviceFormat sensorFormat =\n","prefixes":["libcamera-devel"]}