Skip to content

Commit

Permalink
Add test for old LibcameraAllocator
Browse files Browse the repository at this point in the history
Signed-off-by: William Vinnicombe <[email protected]>
  • Loading branch information
will-v-pi committed Oct 3, 2023
1 parent d17c008 commit 8e989d5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/allocator_test.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions tests/test_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8e989d5

Please sign in to comment.