Patch Detail
Show a patch.
GET /api/patches/15937/?format=api
{ "id": 15937, "url": "https://patchwork.libcamera.org/api/patches/15937/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15937/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20220517143325.71784-14-tomi.valkeinen@ideasonboard.com>", "date": "2022-05-17T14:33:25", "name": "[libcamera-devel,v2,13/13] py: use geometry classes", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "d5b16e309e0fd7f45108afbb6c9560fffabb663e", "submitter": { "id": 109, "url": "https://patchwork.libcamera.org/api/people/109/?format=api", "name": "Tomi Valkeinen", "email": "tomi.valkeinen@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15937/mbox/", "series": [ { "id": 3116, "url": "https://patchwork.libcamera.org/api/series/3116/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3116", "date": "2022-05-17T14:33:12", "name": "Misc Python bindings patches", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3116/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15937/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15937/checks/", "tags": {}, "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 1FB80C3273\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 17 May 2022 14:34:05 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 96F646566D;\n\tTue, 17 May 2022 16:34:04 +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 5D7216567E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 May 2022 16:33:58 +0200 (CEST)", "from deskari.lan (91-156-85-209.elisa-laajakaista.fi\n\t[91.156.85.209])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C61838E6;\n\tTue, 17 May 2022 16:33:57 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652798044;\n\tbh=1+OP/vJ7T6H20/C4248xIS69yVugXiNvae2Aa5nEre4=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=ku7bNdd4bqpejRs9AINRKh708amcI6zKntG+bFlbXhOhD0YV73mwxWILRFVVo+LBS\n\tl9cV83FYkDm5w559WtGhYY2ND26X1ZtCtEBgUYdhKeoVvdghDITnI59dopp9ULc64e\n\tD2Gzv6oWzpolZb/KVTfaPFfldTUE3Z3LdpYP9zoRcLqzGaNo48G3cU1+WYE9uV0aeQ\n\t4tihtJIsnzoborcOmDzlQsp/5m3MuVVDjjhkkKe5uZ3boE/nLhRSJGQHIKZ17c7zM8\n\tOvM/3N+sMlwunNr33D7ldLALTAAPRXIjQxVjSzpBWwaboEq9VWrFerT6RFbjkuR/M3\n\tKJ1h59KT3plXA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652798038;\n\tbh=1+OP/vJ7T6H20/C4248xIS69yVugXiNvae2Aa5nEre4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=dEAya37IirSW9tmdFjHO+qrkjMbI8D2IDcjqWKgokN420YdS0nB0QTxwHtIychVdE\n\t2cPj71nH+Yv8A/EQQh5Nc6499I19QI9+f8ZfUIq4UYU235UNjL1o6USts0sdVsaB0k\n\t0WtJtLuAV5P5G/fiMwO0sRAPGPa9b4CVz3AMPDPQ=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"dEAya37I\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org,\n\tDavid Plowman <david.plowman@raspberrypi.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo@jmondi.org>", "Date": "Tue, 17 May 2022 17:33:25 +0300", "Message-Id": "<20220517143325.71784-14-tomi.valkeinen@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220517143325.71784-1-tomi.valkeinen@ideasonboard.com>", "References": "<20220517143325.71784-1-tomi.valkeinen@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 13/13] py: use geometry classes", "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>", "From": "Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Now that we have proper geometry classes in the Python bindings, change\nthe existing bindings and the .py files accordingly.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/py/cam/cam.py | 7 +++++--\n src/py/cam/cam_kms.py | 3 ++-\n src/py/cam/cam_qt.py | 7 ++++---\n src/py/cam/cam_qtgl.py | 3 ++-\n src/py/libcamera/pymain.cpp | 41 ++++++++-----------------------------\n 5 files changed, 22 insertions(+), 39 deletions(-)", "diff": "diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py\nindex 001fb9de..2f0690b5 100755\n--- a/src/py/cam/cam.py\n+++ b/src/py/cam/cam.py\n@@ -160,8 +160,11 @@ def configure(ctx):\n for idx, stream_opts in enumerate(streams):\n stream_config = camconfig.at(idx)\n \n- if 'width' in stream_opts and 'height' in stream_opts:\n- stream_config.size = (stream_opts['width'], stream_opts['height'])\n+ if 'width' in stream_opts:\n+ stream_config.size.width = stream_opts['width']\n+\n+ if 'height' in stream_opts:\n+ stream_config.size.height = stream_opts['height']\n \n if 'pixelformat' in stream_opts:\n stream_config.pixel_format = libcam.PixelFormat(stream_opts['pixelformat'])\ndiff --git a/src/py/cam/cam_kms.py b/src/py/cam/cam_kms.py\nindex 04381da1..74cd3b38 100644\n--- a/src/py/cam/cam_kms.py\n+++ b/src/py/cam/cam_kms.py\n@@ -126,7 +126,8 @@ class KMSRenderer:\n })\n \n for fb in ctx['allocator'].buffers(stream):\n- w, h = cfg.size\n+ w = cfg.size.width\n+ h = cfg.size.height\n fds = []\n strides = []\n offsets = []\ndiff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py\nindex 45a30aeb..91be2a08 100644\n--- a/src/py/cam/cam_qt.py\n+++ b/src/py/cam/cam_qt.py\n@@ -84,8 +84,8 @@ def demosaic(data, r0, g0, g1, b0):\n \n \n def to_rgb(fmt, size, data):\n- w = size[0]\n- h = size[1]\n+ w = size.width\n+ h = size.height\n \n fmt = str(fmt)\n \n@@ -292,7 +292,8 @@ class MainWindow(QtWidgets.QWidget):\n def buf_to_qpixmap(self, stream, fb):\n with fb.mmap() as mfb:\n cfg = stream.configuration\n- w, h = cfg.size\n+ w = cfg.size.width\n+ h = cfg.size.height\n pitch = cfg.stride\n \n if str(cfg.pixel_format) == 'MJPEG':\ndiff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py\nindex 261accb8..4bbcda6c 100644\n--- a/src/py/cam/cam_qtgl.py\n+++ b/src/py/cam/cam_qtgl.py\n@@ -268,7 +268,8 @@ class MainWindow(QtWidgets.QWidget):\n def create_texture(self, stream, fb):\n cfg = stream.configuration\n fmt = cfg.pixel_format.fourcc\n- w, h = cfg.size\n+ w = cfg.size.width\n+ h = cfg.size.height\n \n attribs = [\n EGL_WIDTH, w,\ndiff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp\nindex 96333ebc..ef3f157a 100644\n--- a/src/py/libcamera/pymain.cpp\n+++ b/src/py/libcamera/pymain.cpp\n@@ -6,7 +6,6 @@\n */\n \n /*\n- * \\todo Add geometry classes (Point, Rectangle...)\n * \\todo Add bindings for the ControlInfo class\n */\n \n@@ -61,11 +60,11 @@ static py::object controlValueToPy(const ControlValue &cv)\n \t\treturn py::cast(cv.get<std::string>());\n \tcase ControlTypeRectangle: {\n \t\tconst Rectangle *v = reinterpret_cast<const Rectangle *>(cv.data().data());\n-\t\treturn py::make_tuple(v->x, v->y, v->width, v->height);\n+\t\treturn py::cast(v);\n \t}\n \tcase ControlTypeSize: {\n \t\tconst Size *v = reinterpret_cast<const Size *>(cv.data().data());\n-\t\treturn py::make_tuple(v->width, v->height);\n+\t\treturn py::cast(v);\n \t}\n \tcase ControlTypeNone:\n \tdefault:\n@@ -99,14 +98,10 @@ static ControlValue pyToControlValue(const py::object &ob, ControlType type)\n \t\treturn controlValueMaybeArray<float>(ob);\n \tcase ControlTypeString:\n \t\treturn ControlValue(ob.cast<std::string>());\n-\tcase ControlTypeRectangle: {\n-\t\tauto array = ob.cast<std::array<int32_t, 4>>();\n-\t\treturn ControlValue(Rectangle(array[0], array[1], array[2], array[3]));\n-\t}\n-\tcase ControlTypeSize: {\n-\t\tauto array = ob.cast<std::array<int32_t, 2>>();\n-\t\treturn ControlValue(Size(array[0], array[1]));\n-\t}\n+\tcase ControlTypeRectangle:\n+\t\treturn ControlValue(ob.cast<Rectangle>());\n+\tcase ControlTypeSize:\n+\t\treturn ControlValue(ob.cast<Size>());\n \tcase ControlTypeNone:\n \tdefault:\n \t\tthrow std::runtime_error(\"Control type not implemented\");\n@@ -397,15 +392,7 @@ PYBIND11_MODULE(_libcamera, m)\n \t\t.def(\"__str__\", &StreamConfiguration::toString)\n \t\t.def_property_readonly(\"stream\", &StreamConfiguration::stream,\n \t\t\t\t py::return_value_policy::reference_internal)\n-\t\t.def_property(\n-\t\t\t\"size\",\n-\t\t\t[](StreamConfiguration &self) {\n-\t\t\t\treturn std::make_tuple(self.size.width, self.size.height);\n-\t\t\t},\n-\t\t\t[](StreamConfiguration &self, std::tuple<uint32_t, uint32_t> size) {\n-\t\t\t\tself.size.width = std::get<0>(size);\n-\t\t\t\tself.size.height = std::get<1>(size);\n-\t\t\t})\n+\t\t.def_readwrite(\"size\", &StreamConfiguration::size)\n \t\t.def_readwrite(\"pixel_format\", &StreamConfiguration::pixelFormat)\n \t\t.def_readwrite(\"stride\", &StreamConfiguration::stride)\n \t\t.def_readwrite(\"frame_size\", &StreamConfiguration::frameSize)\n@@ -416,18 +403,8 @@ PYBIND11_MODULE(_libcamera, m)\n \n \tpyStreamFormats\n \t\t.def_property_readonly(\"pixel_formats\", &StreamFormats::pixelformats)\n-\t\t.def(\"sizes\", [](StreamFormats &self, const PixelFormat &pixelFormat) {\n-\t\t\tstd::vector<std::tuple<uint32_t, uint32_t>> fmts;\n-\t\t\tfor (const auto &s : self.sizes(pixelFormat))\n-\t\t\t\tfmts.push_back(std::make_tuple(s.width, s.height));\n-\t\t\treturn fmts;\n-\t\t})\n-\t\t.def(\"range\", [](StreamFormats &self, const PixelFormat &pixelFormat) {\n-\t\t\tconst auto &range = self.range(pixelFormat);\n-\t\t\treturn make_tuple(std::make_tuple(range.hStep, range.vStep),\n-\t\t\t\t\t std::make_tuple(range.min.width, range.min.height),\n-\t\t\t\t\t std::make_tuple(range.max.width, range.max.height));\n-\t\t});\n+\t\t.def(\"sizes\", &StreamFormats::sizes)\n+\t\t.def(\"range\", &StreamFormats::range);\n \n \tpyFrameBufferAllocator\n \t\t.def(py::init<std::shared_ptr<Camera>>(), py::keep_alive<1, 2>())\n", "prefixes": [ "libcamera-devel", "v2", "13/13" ] }