{"id":18710,"url":"https://patchwork.libcamera.org/api/1.1/patches/18710/?format=json","web_url":"https://patchwork.libcamera.org/patch/18710/","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":"<20230606103336.17782-3-jacopo.mondi@ideasonboard.com>","date":"2023-06-06T10:33:34","name":"[libcamera-devel,v5,2/4] libcamera: rkisp1: Crop on ISP before downscaling","commit_ref":"311e5bc1a8fa06a858e3d930ea57bff796732c8d","pull_url":null,"state":"accepted","archived":false,"hash":"1881faf94db5a6407f8192ef573c3e4ad3206dae","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/1.1/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18710/mbox/","series":[{"id":3909,"url":"https://patchwork.libcamera.org/api/1.1/series/3909/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3909","date":"2023-06-06T10:33:32","name":"libcamera: rkisp1: Fix generateConfiguration","version":5,"mbox":"https://patchwork.libcamera.org/series/3909/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18710/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18710/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 EC227C328F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  6 Jun 2023 10:33:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CF0C46289A;\n\tTue,  6 Jun 2023 12:33:54 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA19062722\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  6 Jun 2023 12:33:52 +0200 (CEST)","from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 692497EC;\n\tTue,  6 Jun 2023 12:33:27 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1686047634;\n\tbh=UUdgzZH/1qvNoEwm+TL4mobgxIZ/Ya5LcSZ8En1dbus=;\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=DSPRTwwQxymJBkcMBitXKJGpzCMMOafqcEJqmOmF+ZEAW5qFaIq2SFr4ySj+x8bz8\n\t/wE+G++wOearZEDBuZtEVneqPp/zQggNA8A7JYGCMPU+2Ytz/dyOpyKbjjgQ7D3Fy7\n\tudPImgdZrs9dgn/OUSM5c3byhJNMtO3JadG6VNJ0dzcf6DrZaOHBXflbREl3dVFswV\n\twIlN7JdmfYdf9xDMQypj5h9nXDTNT/3H2fuYUvJqKoQahoFSRbn9iAodRuzr62d5Xe\n\tCyuPT/c8HDmM4tGdOFMGxdVx6CBgRADris40RFv56ZVhgkNrDEdZiIkBNJagIXfQHo\n\trWlUUAW2bJSUw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1686047607;\n\tbh=UUdgzZH/1qvNoEwm+TL4mobgxIZ/Ya5LcSZ8En1dbus=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=YXufvZSJ/NQBb2r50VnOD5NiDWTelvDBXQMdJBz5ZRTtxobKLh5786wOcMYTsgdN8\n\tJYiGHM+w2/4ZDy5LHUyYFBHDmcPAEmpskc9iGEtRonqMnPI9QuGnf4DtGr4u2P1KGg\n\t8K2u14zS5Y31Qg4MRk8c2xWbdFq2YFVvptZ9Dhb8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"YXufvZSJ\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  6 Jun 2023 12:33:34 +0200","Message-Id":"<20230606103336.17782-3-jacopo.mondi@ideasonboard.com>","X-Mailer":"git-send-email 2.40.1","In-Reply-To":"<20230606103336.17782-1-jacopo.mondi@ideasonboard.com>","References":"<20230606103336.17782-1-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 2/4] libcamera: rkisp1: Crop on ISP\n\tbefore downscaling","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, libcamera@luigi311.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Crop on the resizer sink pad before downscaling to the aspect ratio\nof the desired output size.\n\nCropping the input frame to the output aspect ratio allows to maintain\nthe correct picture proportions, as otherwise downscaling would change\nthe image geometry.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 13 ++++++++++++-\n 1 file changed, 12 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 5079b268c464..0f728cea72b7 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -314,7 +314,18 @@ int RkISP1Path::configure(const StreamConfiguration &config,\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tRectangle rect(0, 0, ispFormat.size);\n+\t/*\n+\t * Crop on the resizer input to maintain FOV before downscaling.\n+\t *\n+\t * \\todo The alignment to a multiple of 2 pixels is required but may\n+\t * change the aspect ratio very slightly. A more advanced algorithm to\n+\t * compute the resizer input crop rectangle is needed, and it should\n+\t * also take into account the need to crop away the edge pixels affected\n+\t * by the ISP processing blocks.\n+\t */\n+\tSize ispCrop = inputFormat.size.boundedToAspectRatio(config.size)\n+\t\t\t\t       .alignedUpTo(2, 2);\n+\tRectangle rect = ispCrop.centeredTo(Rectangle(inputFormat.size).center());\n \tret = resizer_->setSelection(0, V4L2_SEL_TGT_CROP, &rect);\n \tif (ret < 0)\n \t\treturn ret;\n","prefixes":["libcamera-devel","v5","2/4"]}