Skip to content

Commit

Permalink
tests: Add a crop test with the new "perserve_ar" config param
Browse files Browse the repository at this point in the history
Signed-off-by: Naushir Patuck <[email protected]>
  • Loading branch information
naushir authored and davidplowman committed Oct 17, 2024
1 parent a46fb48 commit adbfaa7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/crop_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/python3

# Test setting the "preserve_ar" stream configuration flag

import cv2

from picamera2 import Picamera2

picam2 = Picamera2()

for m, l in [(False, False), (False, True), (True, False), (True, True)]:
cfg = picam2.create_video_configuration(main={"size": (1920, 1080), "format": 'XRGB8888', "preserve_ar": m},
lores={"size": (640, 640), "format": 'YUV420', "preserve_ar": l},
display="main")
picam2.configure(cfg)
picam2.start(show_preview=True)

for _ in range(100):
im = picam2.capture_array("lores")
cv2.imshow("lores", im)
cv2.resizeWindow("lores", (640, 640))
cv2.waitKey(1)

picam2.stop()
1 change: 1 addition & 0 deletions tests/test_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ tests/colour_spaces.py
tests/config_with_sensor.py
tests/configurations.py
tests/context_test.py
tests/crop_test.py
tests/display_transform_null.py
tests/display_transform_qt.py
tests/easy_video2.py
Expand Down

0 comments on commit adbfaa7

Please sign in to comment.