{"id":16008,"url":"https://patchwork.libcamera.org/api/patches/16008/?format=json","web_url":"https://patchwork.libcamera.org/patch/16008/","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":"<20220524114610.41848-3-tomi.valkeinen@ideasonboard.com>","date":"2022-05-24T11:45:53","name":"[libcamera-devel,v2,02/19] 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/16008/mbox/","series":[{"id":3134,"url":"https://patchwork.libcamera.org/api/series/3134/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3134","date":"2022-05-24T11:45:51","name":"More misc Python patches","version":2,"mbox":"https://patchwork.libcamera.org/series/3134/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16008/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16008/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 19C2DBD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 May 2022 11:46:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0C2D265665;\n\tTue, 24 May 2022 13:46:34 +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 0E26565662\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 May 2022 13:46:31 +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 72D138DC;\n\tTue, 24 May 2022 13:46:30 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653392794;\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=qpPAsv78OSasKj7eHNRsn+gDYfk3HX5Dw3mnDFHzw+97FB158B/UwRRMuPNbvpaGh\n\tOaMtu067DmpwpWbfgrfCz4FWUyOllLpad0SWTAg71PdUrB1bsRXdsu38lXI+8J/8Qc\n\tsPMmpjXXwTOH38NUxfym8cMQXt9AHCs+LYMVoSMEti+3/UL+v6Zx/3u2uA+gXMF0qm\n\tm83WIyjn24NtaGW/fn/3X2coP0ZjcpfCbjHdBgcoqEULs3DtvnBXYvEHYk4sp6ujTX\n\tzGTmspJe0Ac+WY6vuqVS85IcKEezPtKAwYyKKB4nacqBHTwDS4B9pkDed4W2r27JGk\n\tEnrhSyiFq2mHQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653392790;\n\tbh=u2tqjxRj2OwecQxi/1sS9LWYVbQZr9S9oBztjV3FNyo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=BMPQYmhfh2NIASyrCInOR8tfz4Ig/u1X3zbYGp7uK70pWPLCePUa2mMIclUgdZ0em\n\tIIGhNZeq9U1T1PrbKC53oJDLKxPQHSbTcl9XPOLqhfcRQUR1b8eW5k3xEkYk8TGTjm\n\tDKeJoo8VSuB/EWRMBsO0C5LN8hNBLy1MykoCjpQw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"BMPQYmhf\"; 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, 24 May 2022 14:45:53 +0300","Message-Id":"<20220524114610.41848-3-tomi.valkeinen@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220524114610.41848-1-tomi.valkeinen@ideasonboard.com>","References":"<20220524114610.41848-1-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 02/19] 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","v2","02/19"]}