{"id":15984,"url":"https://patchwork.libcamera.org/api/patches/15984/?format=json","web_url":"https://patchwork.libcamera.org/patch/15984/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220519103347.33295-3-tomi.valkeinen@ideasonboard.com>","date":"2022-05-19T10:33:44","name":"[libcamera-devel,2/5] py: cam_qt: Use libcamera.formats","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"21fc8817a952033e7df02abe569ff284ab7edb91","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/?format=json","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15984/mbox/","series":[{"id":3127,"url":"https://patchwork.libcamera.org/api/series/3127/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3127","date":"2022-05-19T10:33:42","name":"More misc Python patches","version":1,"mbox":"https://patchwork.libcamera.org/series/3127/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15984/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15984/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 424AAC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 May 2022 10:34:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BE44F65666;\n\tThu, 19 May 2022 12:34:10 +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 732CB60420\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 May 2022 12:34:07 +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 E6FCCE52;\n\tThu, 19 May 2022 12:34:06 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652956450;\n\tbh=u2tqjxRj2OwecQxi/1sS9LWYVbQZr9S9oBztjV3FNyo=;\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=vbXGESsmRvka4LQ7pQmUA+cb/79elwwcEOo/jhDUItlbhr6MpNdXyQw11kbcrE+uZ\n\tbEq3yt2drjPJAxgrfQIsP8OnlAeGFDxOWqmuzEFt/gTBh8VocvYN8PyEtR6XcSy1Cl\n\tusKb/uk785QAzWljqxL8w7FPENaTZR2STI3YkZetTyfCAMnP/9KIWb+xM+hKGk2/N7\n\tL3/A0u1jkN4SoXtgAiI3NHacR1SguoJT7lSGKCHFLweYBOYZy2161TSXf7qX2EYCbI\n\tt3NRaySAG9ZuqGBPNYhG4w6fDD8carh9yxLNprBfgl4zLKc2wD+3YZNLj0sfnxxSXY\n\tQe+QUqGR06Veg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652956447;\n\tbh=u2tqjxRj2OwecQxi/1sS9LWYVbQZr9S9oBztjV3FNyo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=FxU9Nlhyif6fScc2VuT34ri5rf1fbE1OFrN16M8ipSbWBNxoHeYWN1PVn4GF1WVoN\n\tUfZv4vfqA0aV0J7Qgxtt4rw4V9d9RHic38ibUta8Mgw4NHFedeukTGyZbheHKw4VT5\n\tr7WX8pAraW4oIJLKmXBuX/Bj34ux2TY04VRw0kFI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"FxU9Nlhy\"; 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":"Thu, 19 May 2022 13:33:44 +0300","Message-Id":"<20220519103347.33295-3-tomi.valkeinen@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220519103347.33295-1-tomi.valkeinen@ideasonboard.com>","References":"<20220519103347.33295-1-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/5] py: cam_qt: Use libcamera.formats","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":"Use the new libcamera.formats in cam_qt.py.\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_qt.py | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)","diff":"diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py\nindex 91be2a08..0a25a823 100644\n--- a/src/py/cam/cam_qt.py\n+++ b/src/py/cam/cam_qt.py\n@@ -8,6 +8,7 @@ from numpy.lib.stride_tricks import as_strided\n from PIL import Image\n from PIL.ImageQt import ImageQt\n from PyQt5 import QtCore, QtGui, QtWidgets\n+import libcamera as libcam\n import numpy as np\n import sys\n \n@@ -87,9 +88,7 @@ def to_rgb(fmt, size, data):\n     w = size.width\n     h = size.height\n \n-    fmt = str(fmt)\n-\n-    if fmt == 'YUYV':\n+    if fmt == libcam.formats.YUYV:\n         # YUV422\n         yuyv = data.reshape((h, w // 2 * 4))\n \n@@ -111,20 +110,21 @@ def to_rgb(fmt, size, data):\n         rgb[:, :, 2] -= 226.8183044444304\n         rgb = rgb.astype(np.uint8)\n \n-    elif fmt == 'RGB888':\n+    elif fmt == libcam.formats.RGB888:\n         rgb = data.reshape((h, w, 3))\n         rgb[:, :, [0, 1, 2]] = rgb[:, :, [2, 1, 0]]\n \n-    elif fmt == 'BGR888':\n+    elif fmt == libcam.formats.BGR888:\n         rgb = data.reshape((h, w, 3))\n \n-    elif fmt in ['ARGB8888', 'XRGB8888']:\n+    elif fmt in [libcam.formats.ARGB8888, libcam.formats.XRGB8888]:\n         rgb = data.reshape((h, w, 4))\n         rgb = np.flip(rgb, axis=2)\n         # drop alpha component\n         rgb = np.delete(rgb, np.s_[0::4], axis=2)\n \n-    elif fmt.startswith('S'):\n+    elif str(fmt).startswith('S'):\n+        fmt = str(fmt)\n         bayer_pattern = fmt[1:5]\n         bitspp = int(fmt[5:])\n \n@@ -296,7 +296,7 @@ class MainWindow(QtWidgets.QWidget):\n             h = cfg.size.height\n             pitch = cfg.stride\n \n-            if str(cfg.pixel_format) == 'MJPEG':\n+            if cfg.pixel_format == libcam.formats.MJPEG:\n                 img = Image.open(BytesIO(mfb.planes[0]))\n                 qim = ImageQt(img).copy()\n                 pix = QtGui.QPixmap.fromImage(qim)\n","prefixes":["libcamera-devel","2/5"]}