From patchwork Mon Feb 9 11:28:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 26110 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 4FE4CBD78E for ; Mon, 9 Feb 2026 11:28:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6AE58620E7; Mon, 9 Feb 2026 12:28:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lkRYcvBK"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8363A620CB for ; Mon, 9 Feb 2026 12:28:22 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:39aa:ef0c:a929:b3d8]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id A181A454; Mon, 9 Feb 2026 12:27:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1770636456; bh=rorbU4PqTNk3cf9t43h2kdF9CsM54yexUTijKvnpCyQ=; h=From:To:Cc:Subject:Date:From; b=lkRYcvBKcKl8XJKsuzuC/sSWgdJ5NS/GxD39DjiAtVAk8mHm4CI62PgjM7jjV9CvH 3lJ7U2m6q0swINsNkqb6uA+mVVY6mqx6cSi7ImZ8aZ9kyXsFxdyEpfO2kdIBi7asBw zD6ijJgZX5blfDm1sfrQcVQJeahLRwY1N7rj1Bsg= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH] libcamera: dw100_vertexmap: Fix dewarp parameter p2 handling Date: Mon, 9 Feb 2026 12:28:14 +0100 Message-ID: <20260209112818.854064-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The lens dewarp implementation done in commit 1784e08be3a6 ("libcamera: dw100_vertexmap: Implement parametric dewarping") handles the dewarp parameter p2 incorrectly because it uses the already dewarped x value as input for the calculation of the y value. Fix that by using separate variables for the output value. Do so for x and y to keep the code symmetric even if it is only strictly required for y. Fixes: 1784e08be3a6 ("libcamera: dw100_vertexmap: Implement parametric dewarping") Signed-off-by: Stefan Klug Reviewed-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- src/libcamera/converter/converter_dw100_vertexmap.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libcamera/converter/converter_dw100_vertexmap.cpp b/src/libcamera/converter/converter_dw100_vertexmap.cpp index 2cdfe9767a9f..6e238736c435 100644 --- a/src/libcamera/converter/converter_dw100_vertexmap.cpp +++ b/src/libcamera/converter/converter_dw100_vertexmap.cpp @@ -628,6 +628,7 @@ int Dw100VertexMap::setDewarpParams(const Matrix &cm, Vector2d Dw100VertexMap::dewarpPoint(const Vector2d &p) { double x, y; + double xout, yout; double k1 = dewarpCoeffs_[0]; double k2 = dewarpCoeffs_[1]; double p1 = dewarpCoeffs_[2]; @@ -647,11 +648,11 @@ Vector2d Dw100VertexMap::dewarpPoint(const Vector2d &p) double r2 = x * x + y * y; double d = (1 + k1 * r2 + k2 * r2 * r2 + k3 * r2 * r2 * r2) / (1 + k4 * r2 + k5 * r2 * r2 + k6 * r2 * r2 * r2); - x = x * d + 2 * p1 * x * y + p2 * (r2 + 2 * x * x) + s1 * r2 + s2 * r2 * r2; - y = y * d + 2 * p2 * x * y + p1 * (r2 + 2 * y * y) + s3 * r2 + s4 * r2 * r2; + xout = x * d + 2 * p1 * x * y + p2 * (r2 + 2 * x * x) + s1 * r2 + s2 * r2 * r2; + yout = y * d + 2 * p2 * x * y + p1 * (r2 + 2 * y * y) + s3 * r2 + s4 * r2 * r2; - return { { x * dewarpM_[0][0] + y * dewarpM_[0][1] + dewarpM_[0][2], - y * dewarpM_[1][1] + dewarpM_[1][2] } }; + return { { xout * dewarpM_[0][0] + yout * dewarpM_[0][1] + dewarpM_[0][2], + yout * dewarpM_[1][1] + dewarpM_[1][2] } }; } } /* namespace libcamera */