[{"id":39165,"web_url":"https://patchwork.libcamera.org/comment/39165/","msgid":"<20260617144132.GI3054789@killaraus.ideasonboard.com>","date":"2026-06-17T14:41:32","subject":"Re: [PATCH 2/2] libcamera: converter: converter_dw100: Allow to\n\ttransform between different camera matrices","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Wed, Jun 17, 2026 at 11:58:50AM +0200, Stefan Klug wrote:\n> For some use cases (like removing a skew introduced by the camera\n> geometry) it is necessary to define the output camera matrix. Add that\n> functionality by adding an optional tuning parameter \"cmNew\" to the\n> Dewarp configuration. If that parameter is not provided, cm is used\n> instead.\n\nAfter reading the commit message and the patch I have no idea what\n\"cmNew\" is. More effort is required on the documentation side somewhere.\n\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> \n> ---\n> \n> Changes in v0.2:\n> - Swapped cm and cmNew in the output calculation\n> ---\n>  .../converter/converter_dw100_vertexmap.h         |  2 ++\n>  src/libcamera/converter/converter_dw100.cpp       | 15 ++++++++++++++-\n>  .../converter/converter_dw100_vertexmap.cpp       |  8 ++++++--\n>  3 files changed, 22 insertions(+), 3 deletions(-)\n> \n> diff --git a/include/libcamera/internal/converter/converter_dw100_vertexmap.h b/include/libcamera/internal/converter/converter_dw100_vertexmap.h\n> index 787498c7fdb5..d60997f56ad5 100644\n> --- a/include/libcamera/internal/converter/converter_dw100_vertexmap.h\n> +++ b/include/libcamera/internal/converter/converter_dw100_vertexmap.h\n> @@ -33,11 +33,13 @@ public:\n>  \n>  \tstruct DewarpParams {\n>  \t\tDewarpParams() : cm(Matrix<double, 3, 3>::identity()),\n> +\t\t\t\t cmNew(Matrix<double, 3, 3>::identity()),\n>  \t\t\t\t coefficients({})\n>  \t\t{\n>  \t\t}\n>  \n>  \t\tMatrix<double, 3, 3> cm;\n> +\t\tMatrix<double, 3, 3> cmNew;\n>  \n>  \t\tunion {\n>  \t\t\tstruct {\n> diff --git a/src/libcamera/converter/converter_dw100.cpp b/src/libcamera/converter/converter_dw100.cpp\n> index 34f81c6b9fab..97a025b7f961 100644\n> --- a/src/libcamera/converter/converter_dw100.cpp\n> +++ b/src/libcamera/converter/converter_dw100.cpp\n> @@ -104,9 +104,10 @@ int ConverterDW100Module::init(const ValueNode &params)\n>  \n>  \tauto &cm = params[\"cm\"];\n>  \tauto &coefficients = params[\"coefficients\"];\n> +\tauto &cmNew = params[\"cmNew\"];\n>  \n>  \t/* If nothing is provided, the dewarper is still functional */\n> -\tif (!cm && !coefficients)\n> +\tif (!cm && !coefficients && !cmNew)\n>  \t\treturn 0;\n>  \n>  \tif (!cm) {\n> @@ -142,6 +143,18 @@ int ConverterDW100Module::init(const ValueNode &params)\n>  \n>  \tstd::copy(coeffs->begin(), coeffs->end(), &dp.coefficients[0]);\n>  \n> +\tif (cmNew) {\n> +\t\tmatrix = cmNew.get<Matrix<double, 3, 3>>();\n> +\t\tif (!matrix) {\n> +\t\t\tLOG(Converter, Error) << \"Failed to load 'cmNew' value\";\n> +\t\t\treturn -EINVAL;\n> +\t\t}\n> +\n> +\t\tdp.cmNew = *matrix;\n> +\t} else {\n> +\t\tdp.cmNew = dp.cm;\n> +\t}\n> +\n>  \tdewarpParams_ = dp;\n>  \n>  \treturn 0;\n> diff --git a/src/libcamera/converter/converter_dw100_vertexmap.cpp b/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> index 31d992546857..22e08656d36d 100644\n> --- a/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> +++ b/src/libcamera/converter/converter_dw100_vertexmap.cpp\n> @@ -234,6 +234,9 @@ int dw100VerticesForLength(const int length)\n>   * \\var Dw100VertexMap::DewarpParams::cm\n>   * \\brief The camera matrix\n>   *\n> + * \\var Dw100VertexMap::DewarpParams::cmNew\n> + * \\brief The new camera matrix after dewarping\n> + *\n>   * \\var Dw100VertexMap::DewarpParams::coefficient\n>   * \\brief Structure containing the lens dewarp coefficients\n>  \n> @@ -619,10 +622,11 @@ Vector2d Dw100VertexMap::dewarpPoint(const Vector2d &p)\n>  \tdouble x, y;\n>  \tdouble xout, yout;\n>  \tauto &cm = dewarpParams_->cm;\n> +\tauto &cmNew = dewarpParams_->cmNew;\n>  \tauto &c = dewarpParams_->coefficient;\n>  \n> -\ty = (p.y() - cm[1][2]) / cm[1][1];\n> -\tx = (p.x() - cm[0][2] - y * cm[0][1]) / cm[0][0];\n> +\ty = (p.y() - cmNew[1][2]) / cmNew[1][1];\n> +\tx = (p.x() - cmNew[0][2] - y * cmNew[0][1]) / cmNew[0][0];\n>  \n>  \tdouble r2 = x * x + y * y;\n>  \tdouble r4 = r2 * r2;\n> -- \n> 2.53.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 70A47BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 17 Jun 2026 14:41:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 41EDB62894;\n\tWed, 17 Jun 2026 16:41:35 +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 76D7C60579\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Jun 2026 16:41:34 +0200 (CEST)","from killaraus.ideasonboard.com\n\t(2001-14ba-70f3-e800--a06.rev.dnainternet.fi\n\t[IPv6:2001:14ba:70f3:e800::a06])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CA1EC2F8;\n\tWed, 17 Jun 2026 16:40:59 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"DuZ9XRzm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1781707260;\n\tbh=Gw7wKPX/hpxco+8iFf75MaD3r9TZSAN/euyZ9kn4e1M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=DuZ9XRzmfLySW8b4U8sxLVJkL+o4Oh8THYj7tJCPi//dBoxDU4jbpTZi2uR9Dq5Us\n\tWecQNVxqkCyGKURgTjpnojW2E6pYo3JiIyunyhtcI3yBAEdt21LMvnCIGNJlYmp4LQ\n\tHJY9Nez6ub57i+bIOlNhkMDAtN9KRtUoDMbvrD8E=","Date":"Wed, 17 Jun 2026 17:41:32 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 2/2] libcamera: converter: converter_dw100: Allow to\n\ttransform between different camera matrices","Message-ID":"<20260617144132.GI3054789@killaraus.ideasonboard.com>","References":"<20260617095857.667583-1-stefan.klug@ideasonboard.com>\n\t<20260617095857.667583-3-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20260617095857.667583-3-stefan.klug@ideasonboard.com>","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>"}}]