Skip to content

Commit 2d9848e

Browse files
committed
tests: imx500: More robust imx500 testing
Don't read the ID until we are sure the camera has started streaming. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent 94963a7 commit 2d9848e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/imx500.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@
2020

2121
imx500 = IMX500(model_path)
2222

23-
# Test getting the device ID.
24-
device_id = imx500.get_device_id()
25-
print("Device ID:", device_id)
26-
if not device_id:
27-
print("ERROR: empty device ID")
28-
2923
# Start the camera and capture some frames with output tensors.
3024
picam2 = Picamera2(imx500.camera_num)
3125
config = picam2.create_preview_configuration(buffer_count=12)
3226
picam2.configure(config)
3327
picam2.start()
3428

29+
# wait for the device to be streaming before reading id.
30+
picam2.capture_metadata()
31+
device_id = imx500.get_device_id()
32+
print("Device ID:", device_id)
33+
if not device_id:
34+
print("ERROR: empty device ID")
35+
picam2.stop()
36+
picam2.close()
37+
exit()
38+
3539
NUM_FRAMES = 30
3640

3741
tensor_count = 0

0 commit comments

Comments
 (0)