From patchwork Thu May 19 10:33:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15985 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A5421C326C for ; Thu, 19 May 2022 10:34:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1C64E65667; Thu, 19 May 2022 12:34:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652956451; bh=K0Zv9bI44iCQj0lfB8y7MwuuVF7GVni5p82HCXe4F9I=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yudXtiWLSxVvWfs0yZDNJuKnyl2PFihBZ7erPXUZ8AXPUuKa5XiSwGb/ex3JK5ZQB 21tiW7RHY4dofzLI6n7uEnJdQSU9xYJUz8ampx42vwzw1DcQUVfVNH2Nmgsxw6REbb vxXcMAEtzOnvNif6KvbLFgEY2C7vh2sUkf7AZ43bQzR1evw40nRa9KN2vC2OgbNbEj QLJHQixar8gV4XotdWUAhAwo61qWvDDdV6YFYJgVRiAyLxvOV8bfLRBQ3FdWNpkQ9u vjwP4kQiNMfkdX+6CfJB654fdXpdWyDnOQf321VUyu9Fp0dDSn2fn5DBmglojgXm27 0LPelGq94ranQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F40EC60420 for ; Thu, 19 May 2022 12:34:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gm79lZly"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6E64CE53; Thu, 19 May 2022 12:34:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652956447; bh=K0Zv9bI44iCQj0lfB8y7MwuuVF7GVni5p82HCXe4F9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gm79lZly/UAqe/C+fhBIH1QLanc5777Sa8biqyD0S0/H1PQu8yXOyi8QFRyCb6rAu PjDtJpeS3ElfJNybb/jcNSizVKMhogcw1jsA2KS1bfBcSsXbmV5rDZzfEDFIl/9oK9 FX1ERP9cNOIOAM4IngFJDw+o+Mr7y0dgS2Bt4+oQ= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Thu, 19 May 2022 13:33:45 +0300 Message-Id: <20220519103347.33295-4-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 Subject: [libcamera-devel] [PATCH 3/5] py: cam: Cleanups X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" No functional changes. Drop unused variables, reduce typechecker warnings. Signed-off-by: Tomi Valkeinen --- src/py/cam/cam.py | 2 +- src/py/cam/cam_qt.py | 13 ++----------- src/py/cam/cam_qtgl.py | 9 ++------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py index 2f0690b5..e2bc78da 100755 --- a/src/py/cam/cam.py +++ b/src/py/cam/cam.py @@ -304,7 +304,7 @@ def event_handler(state): running = any(ctx['reqs-completed'] < ctx['opt-capture'] for ctx in contexts) return running - except Exception as e: + except Exception: traceback.print_exc() return False diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py index 0a25a823..8dc6f92e 100644 --- a/src/py/cam/cam_qt.py +++ b/src/py/cam/cam_qt.py @@ -184,14 +184,8 @@ class QtRenderer: windows = [] for ctx in self.contexts: - camera = ctx['camera'] - for stream in ctx['streams']: - fmt = stream.configuration.pixel_format - size = stream.configuration.size - window = MainWindow(ctx, stream) - window.setAttribute(QtCore.Qt.WA_ShowWithoutActivating) window.show() windows.append(window) @@ -199,10 +193,10 @@ class QtRenderer: def run(self): camnotif = QtCore.QSocketNotifier(self.cm.efd, QtCore.QSocketNotifier.Read) - camnotif.activated.connect(lambda x: self.readcam()) + camnotif.activated.connect(lambda _: self.readcam()) keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read) - keynotif.activated.connect(lambda x: self.readkey()) + keynotif.activated.connect(lambda _: self.readkey()) print('Capturing...') @@ -292,9 +286,6 @@ class MainWindow(QtWidgets.QWidget): def buf_to_qpixmap(self, stream, fb): with fb.mmap() as mfb: cfg = stream.configuration - w = cfg.size.width - h = cfg.size.height - pitch = cfg.stride if cfg.pixel_format == libcam.formats.MJPEG: img = Image.open(BytesIO(mfb.planes[0])) diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py index 4bbcda6c..3fb7dde3 100644 --- a/src/py/cam/cam_qtgl.py +++ b/src/py/cam/cam_qtgl.py @@ -5,16 +5,11 @@ from PyQt5 import QtCore, QtWidgets from PyQt5.QtCore import Qt import math -import numpy as np import os import sys os.environ['PYOPENGL_PLATFORM'] = 'egl' -import OpenGL -# OpenGL.FULL_LOGGING = True - -from OpenGL import GL as gl from OpenGL.EGL.EXT.image_dma_buf_import import * from OpenGL.EGL.KHR.image import * from OpenGL.EGL.VERSION.EGL_1_0 import * @@ -149,10 +144,10 @@ class QtRenderer: def run(self): camnotif = QtCore.QSocketNotifier(self.state['cm'].efd, QtCore.QSocketNotifier.Read) - camnotif.activated.connect(lambda x: self.readcam()) + camnotif.activated.connect(lambda _: self.readcam()) keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read) - keynotif.activated.connect(lambda x: self.readkey()) + keynotif.activated.connect(lambda _: self.readkey()) print('Capturing...')