[{"id":30036,"web_url":"https://patchwork.libcamera.org/comment/30036/","msgid":"<20240621135211.GM30640@pendragon.ideasonboard.com>","date":"2024-06-21T13:52:11","subject":"Re: [PATCH 2/2] qcam: introduce a command line argument to rotate\n\tthe viewfinder output","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Jun 20, 2024 at 04:36:07PM -0500, Joel Selvaraj wrote:\n> Sometimes devicetrees may not specify the rotation or incorrectly\n> specify it. Introduce a command line argument to quickly test different\n> rotations. This also helps in easily identifying the rotation at which\n> the camera is mounted if kernel developer doesn't already know it.\n> \n> Signed-off-by: Joel Selvaraj <joelselvaraj.oss@gmail.com>\n> ---\n>  src/apps/qcam/main.cpp        |  3 +++\n>  src/apps/qcam/main_window.cpp | 19 +++++++++++++++++++\n>  src/apps/qcam/main_window.h   |  1 +\n>  3 files changed, 23 insertions(+)\n> \n> diff --git a/src/apps/qcam/main.cpp b/src/apps/qcam/main.cpp\n> index 9846fba5..9100c69d 100644\n> --- a/src/apps/qcam/main.cpp\n> +++ b/src/apps/qcam/main.cpp\n> @@ -37,6 +37,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])\n>  \t\t\t ArgumentRequired, \"camera\");\n>  \tparser.addOption(OptHelp, OptionNone, \"Display this help message\",\n>  \t\t\t \"help\");\n> +\tparser.addOption(OptOrientation, OptionString,\n> +\t\t\t \"Desired image orientation (rot0, rot90, rot180, rot270)\",\n> +\t\t\t \"orientation\", ArgumentRequired, \"orientation\");\n>  \tparser.addOption(OptRenderer, OptionString,\n>  \t\t\t \"Choose the renderer type {qt,gles} (default: qt)\",\n>  \t\t\t \"renderer\", ArgumentRequired, \"renderer\");\n> diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp\n> index 18c94cf3..aa4a0fa0 100644\n> --- a/src/apps/qcam/main_window.cpp\n> +++ b/src/apps/qcam/main_window.cpp\n> @@ -399,6 +399,25 @@ int MainWindow::startCapture()\n>  \tif (rotation)\n>  \t\torientation = orientationFromRotation(*rotation);\n>  \n> +\t/* Override if user specifies orientation in command line argument */\n> +\tif (options_.isSet(OptOrientation)) {\n> +\t\tstd::string orientOpt = options_[OptOrientation].toString();\n> +\t\tstatic const std::map<std::string, Orientation> possible_orientations{\n> +\t\t\t{ \"rot0\", Orientation::Rotate0 },\n> +\t\t\t{ \"rot90\", Orientation::Rotate90 },\n> +\t\t\t{ \"rot180\", Orientation::Rotate180 },\n> +\t\t\t{ \"rot270\", Orientation::Rotate270 },\n> +\t\t};\n> +\n> +\t\tauto requested_orientation = possible_orientations.find(orientOpt);\n> +\t\tif (requested_orientation == possible_orientations.end()) {\n> +\t\t\tstd::cerr << \"Unsupported orientation \" << orientOpt << std::endl;\n> +\t\t\treturn -EINVAL;\n> +\t\t}\n> +\n> +\t\torientation = requested_orientation->second;\n\nThere's similar code in src/apps/cam/camera_session.cpp. Is it worth\nmoving it to a helper in src/apps/common/ ? options.cpp could be a\nsuitable candidate.\n\nAnd I think it would be nice if the argument behaved the same way as in\ncam, so it should be used to set config->orientation, overriding the\ndefault Orientation::Rotate0 value.\n\n> +\t}\n> +\n>  \tStreamConfiguration &vfConfig = config_->at(0);\n>  \n>  \t/* Use a format supported by the viewfinder if available. */\n> diff --git a/src/apps/qcam/main_window.h b/src/apps/qcam/main_window.h\n> index 4cead734..6dbcd88d 100644\n> --- a/src/apps/qcam/main_window.h\n> +++ b/src/apps/qcam/main_window.h\n> @@ -40,6 +40,7 @@ class HotplugEvent;\n>  enum {\n>  \tOptCamera = 'c',\n>  \tOptHelp = 'h',\n> +\tOptOrientation = 'o',\n>  \tOptRenderer = 'r',\n>  \tOptStream = 's',\n>  \tOptVerbose = 'v',","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 BD834BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 Jun 2024 13:52:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6FEE3654A9;\n\tFri, 21 Jun 2024 15:52: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 6DC25654A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Jun 2024 15:52:34 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 76E3D8E1;\n\tFri, 21 Jun 2024 15:52:14 +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=\"qNGSkhMF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1718977934;\n\tbh=pmUtf/qBkyXfoz96gufL3JFOBmw3QKbKrnQn4YLPfVE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=qNGSkhMFMgLcRVtO7BVuSo/FEyMx4JqQL+77Oog7CNt8EFFT3SrtrB7SEuRjPgDLV\n\tQQWhPylO0n3hkJl3fYn9dALAPFAXVzrLeyHMQ+s4TreY+lU4nfrQUAZsFnTheU4gxj\n\tGKw5FoNKI2hd9767EHzrkF30PtxIjt2zOT50k2x0=","Date":"Fri, 21 Jun 2024 16:52:11 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Joel Selvaraj <joelselvaraj.oss@gmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 2/2] qcam: introduce a command line argument to rotate\n\tthe viewfinder output","Message-ID":"<20240621135211.GM30640@pendragon.ideasonboard.com>","References":"<20240620213607.32583-1-joelselvaraj.oss@gmail.com>\n\t<20240620213607.32583-3-joelselvaraj.oss@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240620213607.32583-3-joelselvaraj.oss@gmail.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>"}}]