From 9e4388cca5d9ecd6152c0d5990038b515b5f918c Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 27 May 2022 17:44:24 +0300 Subject: py: Move MappedFrameBuffer to libcamera.utils Move MappedFrameBuffer to libcamera.utils, instead of extending FrameBuffer class with a new mmap() method. This keeps us more aligned to the C++ API. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/py/cam/cam.py | 5 +++-- src/py/cam/cam_qt.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/py/cam') diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py index 66df18bf..64f67e86 100755 --- a/src/py/cam/cam.py +++ b/src/py/cam/cam.py @@ -9,6 +9,7 @@ import argparse import binascii import libcamera as libcam +import libcamera.utils import sys import traceback @@ -327,7 +328,7 @@ def request_handler(state, ctx, req): crcs = [] if ctx['opt-crc']: - with fb.mmap() as mfb: + with libcamera.utils.MappedFrameBuffer(fb) as mfb: plane_crcs = [binascii.crc32(p) for p in mfb.planes] crcs.append(plane_crcs) @@ -345,7 +346,7 @@ def request_handler(state, ctx, req): print(f'\t{ctrl} = {val}') if ctx['opt-save-frames']: - with fb.mmap() as mfb: + with libcamera.utils.MappedFrameBuffer(fb) as mfb: filename = 'frame-{}-{}-{}.data'.format(ctx['id'], stream_name, ctx['reqs-completed']) with open(filename, 'wb') as f: for p in mfb.planes: diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py index bff1175b..70bdb7bb 100644 --- a/src/py/cam/cam_qt.py +++ b/src/py/cam/cam_qt.py @@ -9,6 +9,7 @@ from PIL import Image from PIL.ImageQt import ImageQt from PyQt5 import QtCore, QtGui, QtWidgets import libcamera as libcam +import libcamera.utils import numpy as np import sys @@ -285,7 +286,7 @@ class MainWindow(QtWidgets.QWidget): controlsLayout.addStretch() def buf_to_qpixmap(self, stream, fb): - with fb.mmap() as mfb: + with libcamera.utils.MappedFrameBuffer(fb) as mfb: cfg = stream.configuration if cfg.pixel_format == libcam.formats.MJPEG: -- cgit v1.2.1