py: cam: Cleanups

No functional changes. Drop unused variables, reduce typechecker
warnings.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Tomi Valkeinen 2022-05-27 17:44:20 +03:00 committed by Laurent Pinchart
parent 56f9de149f
commit ed0d3a9d71
3 changed files with 5 additions and 18 deletions

View file

@ -304,7 +304,7 @@ def event_handler(state):
running = any(ctx['reqs-completed'] < ctx['opt-capture'] for ctx in contexts) running = any(ctx['reqs-completed'] < ctx['opt-capture'] for ctx in contexts)
return running return running
except Exception as e: except Exception:
traceback.print_exc() traceback.print_exc()
return False return False

View file

@ -184,12 +184,7 @@ class QtRenderer:
windows = [] windows = []
for ctx in self.contexts: for ctx in self.contexts:
camera = ctx['camera']
for stream in ctx['streams']: for stream in ctx['streams']:
fmt = stream.configuration.pixel_format
size = stream.configuration.size
window = MainWindow(ctx, stream) window = MainWindow(ctx, stream)
window.setAttribute(QtCore.Qt.WA_ShowWithoutActivating) window.setAttribute(QtCore.Qt.WA_ShowWithoutActivating)
window.show() window.show()
@ -199,10 +194,10 @@ class QtRenderer:
def run(self): def run(self):
camnotif = QtCore.QSocketNotifier(self.cm.efd, QtCore.QSocketNotifier.Read) 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 = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
keynotif.activated.connect(lambda x: self.readkey()) keynotif.activated.connect(lambda _: self.readkey())
print('Capturing...') print('Capturing...')
@ -292,9 +287,6 @@ class MainWindow(QtWidgets.QWidget):
def buf_to_qpixmap(self, stream, fb): def buf_to_qpixmap(self, stream, fb):
with fb.mmap() as mfb: with fb.mmap() as mfb:
cfg = stream.configuration cfg = stream.configuration
w = cfg.size.width
h = cfg.size.height
pitch = cfg.stride
if cfg.pixel_format == libcam.formats.MJPEG: if cfg.pixel_format == libcam.formats.MJPEG:
img = Image.open(BytesIO(mfb.planes[0])) img = Image.open(BytesIO(mfb.planes[0]))

View file

@ -5,16 +5,11 @@ from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
import math import math
import numpy as np
import os import os
import sys import sys
os.environ['PYOPENGL_PLATFORM'] = 'egl' 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.EXT.image_dma_buf_import import *
from OpenGL.EGL.KHR.image import * from OpenGL.EGL.KHR.image import *
from OpenGL.EGL.VERSION.EGL_1_0 import * from OpenGL.EGL.VERSION.EGL_1_0 import *
@ -149,10 +144,10 @@ class QtRenderer:
def run(self): def run(self):
camnotif = QtCore.QSocketNotifier(self.state['cm'].efd, QtCore.QSocketNotifier.Read) 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 = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
keynotif.activated.connect(lambda x: self.readkey()) keynotif.activated.connect(lambda _: self.readkey())
print('Capturing...') print('Capturing...')