diff --git a/tests/crop_test.py b/tests/crop_test.py new file mode 100644 index 00000000..f920d47d --- /dev/null +++ b/tests/crop_test.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 + +# How to do digital zoom using the "ScalerCrop" control. + +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": 'XRGB8888', "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() diff --git a/tests/test_list.txt b/tests/test_list.txt index cd2cafaf..b26c6e12 100644 --- a/tests/test_list.txt +++ b/tests/test_list.txt @@ -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