Commit a12669fb authored by Yury Matveev's avatar Yury Matveev
Browse files

More strict detection of livestream.

Added tests for livestream
parent 91387a19
Pipeline #9230 passed with stage
in 54 seconds
......@@ -2,16 +2,17 @@ import io
import numpy as np
import hdf5plugin
import h5py
import zlib
from skimage.io import imread
def get_image(data, metadata):
if 'liveimage' in metadata["name"]:
if metadata["name"] == 'liveimage':
image = zlib.decompress(data)
if metadata['meta']['frame_depth'] == 24:
image = np.frombuffer(image, dtype=np.uint32).copy()
image = np.frombuffer(image, dtype=np.uint32)
else:
image = np.frombuffer(image, dtype=np.uint16).copy()
image = np.frombuffer(image, dtype=np.uint16)
image = np.reshape(image, (metadata['meta']['frame_height'],
metadata['meta']['frame_width']))
......
import io
import numpy as np
import sys
import zlib
from AsapoWorker.data_handler import get_image, serialize_ndarray
......@@ -26,3 +27,29 @@ def test_handle_h5():
'name': 'file.h5'}
image2 = get_image(data.getvalue(), metadata)
assert np.alltrue(image == image2)
def test_livestream_24bit():
image = np.random.randint(0, 2**24, (516, 1556)).astype("uint32")
data = image.flatten()
data = zlib.compress(data)
metadata = {'name': 'liveimage',
'meta': {'frame_depth': 24,
'frame_height': 516,
'frame_width': 1556}
}
image2 = get_image(data, metadata)
assert np.alltrue(image == image2)
def test_livestream_12bit():
image = np.random.randint(0, 2**12, (516, 1556)).astype("uint16")
data = image.flatten()
data = zlib.compress(data)
metadata = {'name': 'liveimage',
'meta': {'frame_depth': 12,
'frame_height': 516,
'frame_width': 1556}
}
image2 = get_image(data, metadata)
assert np.alltrue(image == image2)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment