Start to move tests onto new camera api

This commit is contained in:
Julian Stirling 2026-05-27 23:28:19 +01:00
parent c18d43a3a5
commit b9c6071bc7
5 changed files with 10 additions and 10 deletions

View file

@ -26,7 +26,7 @@ def test_jpeg_and_array(picamera_client):
assert jpeg_capture.format == "JPEG" assert jpeg_capture.format == "JPEG"
# Capture an array # Capture an array
arrlist = picamera_client.capture_array(stream_name="main") arrlist = picamera_client.capture_as_array(stream_name="main")
array_main = np.array(arrlist) array_main = np.array(arrlist)
# Verify image sizes are the same # Verify image sizes are the same

View file

@ -14,7 +14,7 @@ def test_streaming_mode():
with camera_test_client() as client: with camera_test_client() as client:
for mode, res in ["default", (820, 616)], ["full_resolution", (3280, 2464)]: for mode, res in ["default", (820, 616)], ["full_resolution", (3280, 2464)]:
client.change_streaming_mode(mode=mode) client.change_streaming_mode(mode=mode)
arr = np.array(client.capture_array(stream_name="main")) arr = np.array(client.capture_as_array(stream_name="main"))
# Check that the array dimensions match the requested image size. # Check that the array dimensions match the requested image size.
# Note: Numpy array shape is (y,x), but the sensor is set with (x,y) # Note: Numpy array shape is (y,x), but the sensor is set with (x,y)
# hence the need to compare index 0 with index 1. # hence the need to compare index 0 with index 1.

View file

@ -77,10 +77,10 @@ def test_stage(simulation_test_env):
assert start["z"] == pos["z"] assert start["z"] == pos["z"]
def test_capture_array(simulation_test_env): def test_capture_as_array(simulation_test_env):
"""Capture array from simulation and check the size is as expected.""" """Capture array from simulation and check the size is as expected."""
camera = simulation_test_env.get_thing_client("camera") camera = simulation_test_env.get_thing_client("camera")
array = np.asarray(camera.capture_array()) array = np.asarray(camera.capture_as_array())
assert array.shape == (616, 820, 3) assert array.shape == (616, 820, 3)

View file

@ -169,9 +169,9 @@ def test_picamera_metadata_written_to_exif(mock_picam_thing, temp_jpeg, mocker):
mock_interface.get_thing_states.return_value = camera.thing_state mock_interface.get_thing_states.return_value = camera.thing_state
camera._thing_server_interface = mock_interface camera._thing_server_interface = mock_interface
capture_metadata = camera._capture_metadata() ofm_metadata = camera._collect_ofm_metadata()
camera._add_metadata_to_capture(str(temp_jpeg), capture_metadata) camera._add_metadata_to_capture(str(temp_jpeg), ofm_metadata)
exif_dict = piexif.load(str(temp_jpeg)) exif_dict = piexif.load(str(temp_jpeg))
user_comment = json.loads(exif_dict["Exif"][piexif.ExifIFD.UserComment].decode()) user_comment = json.loads(exif_dict["Exif"][piexif.ExifIFD.UserComment].decode())

View file

@ -159,12 +159,12 @@ def test_infinite_sample(camera, stage):
camera.noise_level = 0 camera.noise_level = 0
assert not camera.repeating assert not camera.repeating
cached_canvas = camera.canvas cached_canvas = camera.canvas
array_not_repeating = camera.capture_array() array_not_repeating = camera.capture_as_array()
camera.repeating = True camera.repeating = True
time.sleep(0.2) # Ensure frame regenerates time.sleep(0.2) # Ensure frame regenerates
# Canvas shouldn't regenerate # Canvas shouldn't regenerate
assert camera.canvas is cached_canvas assert camera.canvas is cached_canvas
array_repeating = camera.capture_array() array_repeating = camera.capture_as_array()
# Images are identical whether or not repeating # Images are identical whether or not repeating
assert np.array_equal(array_not_repeating, array_repeating) assert np.array_equal(array_not_repeating, array_repeating)
@ -174,13 +174,13 @@ def test_infinite_sample(camera, stage):
camera.repeating = False camera.repeating = False
time.sleep(0.2) # Ensure frame regenerates time.sleep(0.2) # Ensure frame regenerates
# If not repeating the array is just background # If not repeating the array is just background
assert np.all(camera.capture_array() == simulation.BG_COLOR) assert np.all(camera.capture_as_array() == simulation.BG_COLOR)
# Turn on repeating # Turn on repeating
camera.repeating = True camera.repeating = True
time.sleep(0.2) # Ensure frame regenerates time.sleep(0.2) # Ensure frame regenerates
# Sample is now infinite, so not all background # Sample is now infinite, so not all background
assert not np.all(camera.capture_array() == simulation.BG_COLOR) assert not np.all(camera.capture_as_array() == simulation.BG_COLOR)
def test_simulation_cam_calibration(camera): def test_simulation_cam_calibration(camera):