Patch Detail
Show a patch.
GET /api/1.1/patches/15918/?format=api
{ "id": 15918, "url": "https://patchwork.libcamera.org/api/1.1/patches/15918/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15918/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20220516141022.96327-13-tomi.valkeinen@ideasonboard.com>", "date": "2022-05-16T14:10:20", "name": "[libcamera-devel,12/14] py: use geometry classes", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "ae6caceb26b1b37f3071cdb50f7c620d02bb405b", "submitter": { "id": 109, "url": "https://patchwork.libcamera.org/api/1.1/people/109/?format=api", "name": "Tomi Valkeinen", "email": "tomi.valkeinen@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15918/mbox/", "series": [ { "id": 3113, "url": "https://patchwork.libcamera.org/api/1.1/series/3113/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3113", "date": "2022-05-16T14:10:08", "name": "Misc Python bindings patches", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3113/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15918/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15918/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 D0D20C326E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 May 2022 14:11:03 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 604E86567C;\n\tMon, 16 May 2022 16:11:03 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1BBB561FB8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 May 2022 16:10:54 +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 80E8F48F;\n\tMon, 16 May 2022 16:10:53 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652710263;\n\tbh=qO9eZeY+UmGt+WPdTtX/QwrNzHBKP0FK3kHiLR9Xleo=;\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=l9BhMmOlCwLXotjb83LG04xPpewa082aY9bXdhqRAyv+d4sApqthr+9Up4uYxA8MS\n\tmZlDutP3RKNg2HwTXW8D4rAyzgiKASSLngATdN/H4YJQemjp6nm5LmBv1m/4IwldJ7\n\tCEfeBioxXQh4MHPKIa6d++RIRQYUPy3AURt9rxJRKD2ZqIS40UIoQ3izwDKJWBG7I6\n\tu+A7813TXTrKD5maHsvWuQCzcUTstgBKs+s4+Vx7KSAya3/R1UHIxQQXH4q6fi+zaI\n\tB8Cqo/FAD8/SaeYJvS/xLbF8j/yrGw2jVw3flzb5egsjd70zoU+o0g24j6CrtvVpHu\n\tYRKthF6Z2ApSA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652710253;\n\tbh=qO9eZeY+UmGt+WPdTtX/QwrNzHBKP0FK3kHiLR9Xleo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=DxZslWE/SwRBloosc1sELMO5ZDKyLl/RDXuwkkQoW0s76GDgsbc3cDIdJTWcm2xmC\n\t9vZDoVBXRNphBuU8yrYjHGrXW1keT50ik++nacwIHuyfYfuKSIPTf7EMbunCEeVvyJ\n\tCztHX9hsuCfPYgl5qkirvkNYGnJuA7pcPPOzHLhA=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"DxZslWE/\"; 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": "Mon, 16 May 2022 17:10:20 +0300", "Message-Id": "<20220516141022.96327-13-tomi.valkeinen@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220516141022.96327-1-tomi.valkeinen@ideasonboard.com>", "References": "<20220516141022.96327-1-tomi.valkeinen@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 12/14] 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>\n---\n src/py/cam/cam.py | 7 ++++--\n src/py/cam/cam_kms.py | 3 ++-\n src/py/cam/cam_qt.py | 3 ++-\n src/py/cam/cam_qtgl.py | 3 ++-\n src/py/libcamera/pymain.cpp | 41 ++++++++--------------------------\n src/py/libcamera/utils/conv.py | 4 ++--\n 6 files changed, 22 insertions(+), 39 deletions(-)", "diff": "diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py\nindex 63c67126..347175b7 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.from_name(stream_opts['pixelformat'])\ndiff --git a/src/py/cam/cam_kms.py b/src/py/cam/cam_kms.py\nindex 7d11564b..da3dd4e0 100644\n--- a/src/py/cam/cam_kms.py\n+++ b/src/py/cam/cam_kms.py\n@@ -125,7 +125,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 stride = cfg.stride\n fd = fb.fd(0)\n drmfb = pykms.DmabufFramebuffer(self.card, w, h, fmt,\ndiff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py\nindex 64f49f33..8bef9b57 100644\n--- a/src/py/cam/cam_qt.py\n+++ b/src/py/cam/cam_qt.py\n@@ -136,7 +136,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 cfg.pixel_format.name == '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 1dd70d9c..d7bd71ef 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>())\ndiff --git a/src/py/libcamera/utils/conv.py b/src/py/libcamera/utils/conv.py\nindex 30f6733e..5a4bc282 100644\n--- a/src/py/libcamera/utils/conv.py\n+++ b/src/py/libcamera/utils/conv.py\n@@ -73,8 +73,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 = fmt.name\n \n", "prefixes": [ "libcamera-devel", "12/14" ] }