From 8e989d599f1314d96eebc2d4f249b65f13f03bde Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Tue, 3 Oct 2023 14:35:26 +0100 Subject: [PATCH] Add test for old LibcameraAllocator Signed-off-by: William Vinnicombe --- tests/allocator_test.py | 30 ++++++++++++++++++++++++++++++ tests/test_list.txt | 1 + 2 files changed, 31 insertions(+) create mode 100644 tests/allocator_test.py diff --git a/tests/allocator_test.py b/tests/allocator_test.py new file mode 100644 index 00000000..85924d46 --- /dev/null +++ b/tests/allocator_test.py @@ -0,0 +1,30 @@ +#!/usr/bin/python3 + +# Test that the LibcameraAllocator still works, based off switch_mode example + +import time + +from picamera2 import Picamera2, Preview +from picamera2.allocators import LibcameraAllocator + +picam2 = Picamera2() +picam2.allocator = LibcameraAllocator(picam2.camera) +picam2.start_preview(Preview.QTGL) + +preview_config = picam2.create_preview_configuration() +picam2.configure(preview_config) + +picam2.start() +time.sleep(2) + +size = picam2.sensor_resolution +# GPU won't digest images wider than 4096 on a Pi 4. +if size[0] > 4096: + height = size[1] * 4096 // size[0] + height -= height % 2 + size = (4096, height) + +other_config = picam2.create_preview_configuration(main={"size": size}, buffer_count=2) + +picam2.switch_mode(other_config) +time.sleep(2) diff --git a/tests/test_list.txt b/tests/test_list.txt index 8b5b1e51..163d6ecb 100644 --- a/tests/test_list.txt +++ b/tests/test_list.txt @@ -71,3 +71,4 @@ tests/preview_start_stop.py tests/quality_check.py tests/qt_gl_preview_test.py tests/stop_slow_framerate.py +tests/allocator_test.py