[{"id":38153,"web_url":"https://patchwork.libcamera.org/comment/38153/","msgid":"<0e7641fd-a872-44bd-990e-3e9d0f869848@ideasonboard.com>","date":"2026-02-09T12:40:25","subject":"Re: [PATCH] libcamera: dw100_vertexmap: Fix dewarp parameter p2\n\thandling","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 02. 09. 12:28 keltezéssel, Stefan Klug írta:\n> The lens dewarp implementation done in commit 1784e08be3a6 (\"libcamera:\n> dw100_vertexmap: Implement parametric dewarping\") handles the dewarp\n> parameter p2 incorrectly because it uses the already dewarped x value as\n> input for the calculation of the y value. Fix that by using separate\n> variables for the output value. Do so for x and y to keep the code\n> symmetric even if it is only strictly required for y.\n> \n> Fixes: 1784e08be3a6 (\"libcamera: dw100_vertexmap: Implement parametric dewarping\")\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n\nLooks ok to me.\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n>   src/libcamera/converter/converter_dw100_vertexmap.cpp | 9 +++++----\n>   1 file changed, 5 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/converter/converter_dw100_vertexmap.cpp b/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> index 2cdfe9767a9f..6e238736c435 100644\n> --- a/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> +++ b/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> @@ -628,6 +628,7 @@ int Dw100VertexMap::setDewarpParams(const Matrix<double, 3, 3> &cm,\n>   Vector2d Dw100VertexMap::dewarpPoint(const Vector2d &p)\n>   {\n>   \tdouble x, y;\n> +\tdouble xout, yout;\n>   \tdouble k1 = dewarpCoeffs_[0];\n>   \tdouble k2 = dewarpCoeffs_[1];\n>   \tdouble p1 = dewarpCoeffs_[2];\n> @@ -647,11 +648,11 @@ Vector2d Dw100VertexMap::dewarpPoint(const Vector2d &p)\n>   \tdouble r2 = x * x + y * y;\n>   \tdouble d = (1 + k1 * r2 + k2 * r2 * r2 + k3 * r2 * r2 * r2) /\n>   \t\t   (1 + k4 * r2 + k5 * r2 * r2 + k6 * r2 * r2 * r2);\n> -\tx = x * d + 2 * p1 * x * y + p2 * (r2 + 2 * x * x) + s1 * r2 + s2 * r2 * r2;\n> -\ty = y * d + 2 * p2 * x * y + p1 * (r2 + 2 * y * y) + s3 * r2 + s4 * r2 * r2;\n> +\txout = x * d + 2 * p1 * x * y + p2 * (r2 + 2 * x * x) + s1 * r2 + s2 * r2 * r2;\n> +\tyout = y * d + 2 * p2 * x * y + p1 * (r2 + 2 * y * y) + s3 * r2 + s4 * r2 * r2;\n> \n> -\treturn { { x * dewarpM_[0][0] + y * dewarpM_[0][1] + dewarpM_[0][2],\n> -\t\t   y * dewarpM_[1][1] + dewarpM_[1][2] } };\n> +\treturn { { xout * dewarpM_[0][0] + yout * dewarpM_[0][1] + dewarpM_[0][2],\n> +\t\t   yout * dewarpM_[1][1] + dewarpM_[1][2] } };\n>   }\n> \n>   } /* namespace libcamera */\n> --\n> 2.51.0\n>","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 DCD33BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  9 Feb 2026 12:40:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E322961FA0;\n\tMon,  9 Feb 2026 13:40:30 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F44461FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  9 Feb 2026 13:40:29 +0100 (CET)","from [192.168.33.63] (185.221.141.206.nat.pool.zt.hu\n\t[185.221.141.206])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1C49063F;\n\tMon,  9 Feb 2026 13:39:43 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"a0VZM0/s\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1770640783;\n\tbh=Ir+dZQwJmTX+3Ru1vgZYI+m3KE8EPk5dpq1+uLG3VWI=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=a0VZM0/sSbDQHyXyn5H6Lp9nviJl4jirqvkv10X5iVOSxrWGYiNsvir87HHOKfR5W\n\toBaDe8rkyY6CLK7918TchJcmlQMG1nYDbTH6dhA+omXAuXjyaNWineeMKcrOCaJ6IY\n\tkzT7WSjCj4aCXufHxiqH/oIss/AHhmqrolhllCOY=","Message-ID":"<0e7641fd-a872-44bd-990e-3e9d0f869848@ideasonboard.com>","Date":"Mon, 9 Feb 2026 13:40:25 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] libcamera: dw100_vertexmap: Fix dewarp parameter p2\n\thandling","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<ambOd3HuRyAvvIPyctFYOmx37fxEiSSR8eGjCHrpPx8gGK9F9V9weG97dASt_LJ3IF6GUv5C_7TjJ7dUlfw4zA==@protonmail.internalid>\n\t<20260209112818.854064-1-stefan.klug@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260209112818.854064-1-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":38157,"web_url":"https://patchwork.libcamera.org/comment/38157/","msgid":"<177064913715.1693075.12376775398950016163@ping.linuxembedded.co.uk>","date":"2026-02-09T14:58:57","subject":"Re: [PATCH] libcamera: dw100_vertexmap: Fix dewarp parameter p2\n\thandling","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2026-02-09 11:28:14)\n> The lens dewarp implementation done in commit 1784e08be3a6 (\"libcamera:\n> dw100_vertexmap: Implement parametric dewarping\") handles the dewarp\n> parameter p2 incorrectly because it uses the already dewarped x value as\n> input for the calculation of the y value. Fix that by using separate\n> variables for the output value. Do so for x and y to keep the code\n> symmetric even if it is only strictly required for y.\n> \n> Fixes: 1784e08be3a6 (\"libcamera: dw100_vertexmap: Implement parametric dewarping\")\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/libcamera/converter/converter_dw100_vertexmap.cpp | 9 +++++----\n>  1 file changed, 5 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/converter/converter_dw100_vertexmap.cpp b/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> index 2cdfe9767a9f..6e238736c435 100644\n> --- a/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> +++ b/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> @@ -628,6 +628,7 @@ int Dw100VertexMap::setDewarpParams(const Matrix<double, 3, 3> &cm,\n>  Vector2d Dw100VertexMap::dewarpPoint(const Vector2d &p)\n>  {\n>         double x, y;\n> +       double xout, yout;\n>         double k1 = dewarpCoeffs_[0];\n>         double k2 = dewarpCoeffs_[1];\n>         double p1 = dewarpCoeffs_[2];\n> @@ -647,11 +648,11 @@ Vector2d Dw100VertexMap::dewarpPoint(const Vector2d &p)\n>         double r2 = x * x + y * y;\n>         double d = (1 + k1 * r2 + k2 * r2 * r2 + k3 * r2 * r2 * r2) /\n>                    (1 + k4 * r2 + k5 * r2 * r2 + k6 * r2 * r2 * r2);\n> -       x = x * d + 2 * p1 * x * y + p2 * (r2 + 2 * x * x) + s1 * r2 + s2 * r2 * r2;\n> -       y = y * d + 2 * p2 * x * y + p1 * (r2 + 2 * y * y) + s3 * r2 + s4 * r2 * r2;\n> +       xout = x * d + 2 * p1 * x * y + p2 * (r2 + 2 * x * x) + s1 * r2 + s2 * r2 * r2;\n> +       yout = y * d + 2 * p2 * x * y + p1 * (r2 + 2 * y * y) + s3 * r2 + s4 * r2 * r2;\n>  \n> -       return { { x * dewarpM_[0][0] + y * dewarpM_[0][1] + dewarpM_[0][2],\n> -                  y * dewarpM_[1][1] + dewarpM_[1][2] } };\n> +       return { { xout * dewarpM_[0][0] + yout * dewarpM_[0][1] + dewarpM_[0][2],\n> +                  yout * dewarpM_[1][1] + dewarpM_[1][2] } };\n\nLooks sane,\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>  }\n>  \n>  } /* namespace libcamera */\n> -- \n> 2.51.0\n>","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 42C37C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  9 Feb 2026 14:59:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2798C62119;\n\tMon,  9 Feb 2026 15:59:02 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E330A61FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  9 Feb 2026 15:58:59 +0100 (CET)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D62CEBD2;\n\tMon,  9 Feb 2026 15:58:13 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RaoV61Ga\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1770649093;\n\tbh=Yf8Ym+nMnbMH471RDgL6oWroUjt10o9pYY5Sa+nbIY8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=RaoV61Ga/hxrqOJp3ZaxRkfQHnNepK9+qO3yvX8TNTxEv3o3bJzlvwLX2630MBEqa\n\tqiW9n8iKNadl7LLFOzNu6G022m8APZ9+/OMh0K0J1oTyhaMIlBbDls+s23e9YgR97Y\n\tdLqNbN4SVSW7YzXgw2bAFLISteGgPEFnSJUVPVYQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260209112818.854064-1-stefan.klug@ideasonboard.com>","References":"<20260209112818.854064-1-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH] libcamera: dw100_vertexmap: Fix dewarp parameter p2\n\thandling","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 09 Feb 2026 14:58:57 +0000","Message-ID":"<177064913715.1693075.12376775398950016163@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]