Apply suggestions from code review of branch jpeg-capture-in-stacking
Co-authored-by: Beth Probert <beth_probert@outlook.com>
This commit is contained in:
parent
2d49bf2061
commit
0933ece63a
8 changed files with 43 additions and 15 deletions
|
|
@ -11,6 +11,11 @@ from openflexure_microscope_server.things.camera.picamera import StreamingPiCame
|
|||
|
||||
@fixture(scope="module")
|
||||
def client():
|
||||
"""
|
||||
A pytest fixture that initialises a test client for the StreamingPiCamera2 Thing.
|
||||
This fixture sets up a ThingServer, registers a StreamingPiCamera2 instance at the
|
||||
"/camera/" endpoint, and provides a ThingClient for interacting with it during tests.
|
||||
"""
|
||||
server = ThingServer()
|
||||
server.add_thing(StreamingPiCamera2(), "/camera/")
|
||||
with TestClient(server.app) as test_client:
|
||||
|
|
@ -30,13 +35,20 @@ def test_jpeg_and_array(client):
|
|||
Check that grabbing a jpeg from the stream results in the same size
|
||||
image as a array capture or a jpeg capture.
|
||||
"""
|
||||
# Grab a jpeg from the stream
|
||||
blob = client.grab_jpeg()
|
||||
mjpeg_frame = Image.open(blob.open())
|
||||
assert mjpeg_frame
|
||||
|
||||
# Capture a jpeg
|
||||
blob = client.capture_jpeg(resolution="main")
|
||||
jpeg_capture = Image.open(blob.open())
|
||||
assert jpeg_capture
|
||||
|
||||
# Capture an array
|
||||
arrlist = client.capture_array(stream_name="main")
|
||||
array_main = np.array(arrlist)
|
||||
|
||||
# Verify image sizes are the same
|
||||
assert mjpeg_frame.size == jpeg_capture.size
|
||||
assert array_main.shape[1::-1] == jpeg_capture.size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue