48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import numpy as np
|
|
|
|
import orisys
|
|
|
|
|
|
def test_import_version():
|
|
assert isinstance(orisys.__version__, str)
|
|
assert len(orisys.__version__) > 0
|
|
|
|
|
|
def test_sensor_smoke_pipeline(sensor_factory):
|
|
sensor = sensor_factory(backend="cpu")
|
|
try:
|
|
img = sensor.get_img()
|
|
assert img is not None
|
|
assert isinstance(img, np.ndarray)
|
|
assert img.ndim in (2, 3)
|
|
|
|
result = sensor.compute_deformation(check_motion=False, threshold=6)
|
|
assert result is None
|
|
|
|
flow, vnormal, vshear = sensor.read_info(
|
|
sensor.info.VRAW,
|
|
sensor.info.VNORMAL,
|
|
sensor.info.VSHEAR,
|
|
)
|
|
assert flow.ndim == 3 and flow.shape[-1] == 2
|
|
assert vnormal.shape == flow.shape
|
|
assert vshear.shape == flow.shape
|
|
assert np.isfinite(flow).all()
|
|
assert np.isfinite(vnormal).all()
|
|
assert np.isfinite(vshear).all()
|
|
|
|
fnormal, fsx, fsy = sensor.read_info(
|
|
sensor.info.FNORMAL,
|
|
sensor.info.FSHEARX,
|
|
sensor.info.FSHEARY,
|
|
)
|
|
assert np.isfinite([fnormal, fsx, fsy]).all()
|
|
|
|
contact = sensor.compute_contact()
|
|
assert isinstance(contact, dict)
|
|
assert "centroid_found" in contact
|
|
assert "divergence_map" in contact
|
|
assert isinstance(contact["divergence_map"], np.ndarray)
|
|
finally:
|
|
sensor.disconnect()
|