Show a patch.

GET /api/patches/15964/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 15964,
    "url": "https://patchwork.libcamera.org/api/patches/15964/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15964/",
    "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": "<20220518131329.66994-15-tomi.valkeinen@ideasonboard.com>",
    "date": "2022-05-18T13:13:25",
    "name": "[libcamera-devel,v3,14/18] py: use geometry classes",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "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/15964/mbox/",
    "series": [
        {
            "id": 3122,
            "url": "https://patchwork.libcamera.org/api/series/3122/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3122",
            "date": "2022-05-18T13:13:11",
            "name": "Misc Python bindings patches",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3122/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15964/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15964/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 82069C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 May 2022 13:14:08 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1C0716567C;\n\tWed, 18 May 2022 15:14:08 +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 942BE6565D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 May 2022 15:13:53 +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 0EE82221E;\n\tWed, 18 May 2022 15:13:53 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652879648;\n\tbh=G+8n/1pEFurPhZQdtmvMaEp+ig2oS10Exqa4JPW881o=;\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=byr3gG4yR7qSFGlo7tgyidKOfL6YBGUYninokGh1pI3pjuJemqes1WP0FVd9m11uc\n\tM+hIl02/rwjLrqki+Y36pZlyPi9XEM95WYzxwPOLj3TruNHbdGS+BthmjGKOcAIB+6\n\tu8MXuwPnNshjXz7dRQHSOmyOMBFxhexe9Mr0aFJUnGsBEuz/HIOTQ/m9FzSeBMAfJ9\n\tKT137zIMIu76F5Yyif+NgZmvGdN068ZNdlPSZwt4CZ7u94MKZTQakUucX3kn/B3+Z1\n\tLroGN9c1+1Zi2lOOJA+W56czHwiIaAEMyRqstA76L2fAME8vGmClAzqCM1OrDvGktG\n\txKKocXKCBprEQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652879633;\n\tbh=G+8n/1pEFurPhZQdtmvMaEp+ig2oS10Exqa4JPW881o=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=qNrlfcO/PpFjuIKKoJYTZ+eZ+K+UnA+See+J835IilSI+RDMaKIspQ91eOnfL8gRm\n\t4jRLa2c/ke3/TL92bmbOPlA6uqoat9HyHpvTDFPVOUjwtpiA2JMZO5JswlFKVmGYgN\n\tQlkfpN1/I6fObqb0g4ovyYUJruP5OZy8h1eYroHo="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"qNrlfcO/\"; 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": "Wed, 18 May 2022 16:13:25 +0300",
        "Message-Id": "<20220518131329.66994-15-tomi.valkeinen@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20220518131329.66994-1-tomi.valkeinen@ideasonboard.com>",
        "References": "<20220518131329.66994-1-tomi.valkeinen@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 14/18] 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>\nReviewed-by: Kieran Bingham <kieran.bingham@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",
        "v3",
        "14/18"
    ]
}