From patchwork Tue Mar 21 17:20:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18424 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6D631C0F1B for ; Tue, 21 Mar 2023 17:20:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3458C62719; Tue, 21 Mar 2023 18:20:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679419216; bh=gfpR6WY5VdmZ4+VagB9ZikFbjj76SIiQWSxCcO0Y60Y=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=plVBMcPF7c3jGmUp37J8RtpcQcaI1xw+gWTFFs+wBO3Nfs141gB9KEERpV7LvxRSe kqCmWU/CChieqtCH6Jxx0HmEdT2BpcakzBOZS5o0DZDNc+yuqJkjhq9bUDAM4ip1N3 BFMJfpCVzHDoy9Ii9Dbaknorgj5g9X9+1X0/E8W0lSSfyr7azH4PNCBjOckM3zUkOc fUjLze4yYOJPPJfAHz4UbPhNVF5BTTuEk0Vovf+hkBnn4McVEZcCnEAjDW4CO05bh9 0sqExol1vGd5OHNor+RVc+XzgiZVOZrP/yNGsUFp4H2asd3GtrpiuA9hpb4wwEc1Tn x7a94UdEQnjmw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F9606270F for ; Tue, 21 Mar 2023 18:20:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="co6/vtgF"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-18-61-243.retail.telecomitalia.it [87.18.61.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AB1CA80A; Tue, 21 Mar 2023 18:20:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1679419213; bh=gfpR6WY5VdmZ4+VagB9ZikFbjj76SIiQWSxCcO0Y60Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=co6/vtgFmiZLbLdWK6XbkVKj6Z0xQI7R3ZgOG5n9s9V6tfk8FF1ujXhi1xIrH9iv4 TLXgUcts2BgotMlLqLFOEk+mBwcvJHSWkxFPs4GZhQ0nX0Duc6pD4nMHXSstN5j/Uq nMa93nP5f3wnSTPo19pouZns9hdVGi0e/OlceWhE= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Mar 2023 18:20:02 +0100 Message-Id: <20230321172004.176852-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> References: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/4] libcamera: rkisp1: Crop on ISP before downscaling X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi , libcamera@luigi311.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Crop on the resizer sink pad before downscaling to the aspect ratio of the desired output size. Cropping the input frame to the output aspect ratio allows to maintain the correct picture proportions, as otherwise downscaling would change the image geometry. Signed-off-by: Jacopo Mondi Reviewed-by: Umang Jain --- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index 5079b268c464..5547cc32b6ca 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -314,7 +314,10 @@ int RkISP1Path::configure(const StreamConfiguration &config, if (ret < 0) return ret; - Rectangle rect(0, 0, ispFormat.size); + /* Crop on the resizer input to maintain FOV before downscaling */ + Size ispCrop = inputFormat.size.boundedToAspectRatio(config.size) + .alignedUpTo(2, 2); + Rectangle rect(ispCrop); ret = resizer_->setSelection(0, V4L2_SEL_TGT_CROP, &rect); if (ret < 0) return ret;