Skip to content
Snippets Groups Projects
Commit f6956c39 authored by Vincent POLLET's avatar Vincent POLLET
Browse files

Merge branch 'subtract_unit_test' into 'master'

Implements unit test for the subtract stream filter

See merge request !6
parents e6b8a269 b6ff6fd6
Branches
Tags
1 merge request!6Implements unit test for the subtract stream filter
Pipeline #42134 passed
bob/io/stream/test/data/swir_940_dark_subtract.png

429 KiB

...@@ -39,6 +39,7 @@ def test_stream(): ...@@ -39,6 +39,7 @@ def test_stream():
gt_depth = load(resource_path("test/data/reprojection_depth.png")) gt_depth = load(resource_path("test/data/reprojection_depth.png"))
gt_warp_thermal = load(resource_path("test/data/warp_thermal.png")) gt_warp_thermal = load(resource_path("test/data/warp_thermal.png"))
gt_warp_swir = load(resource_path("test/data/warp_swir_norm.png")) gt_warp_swir = load(resource_path("test/data/warp_swir_norm.png"))
gt_swir_940_dark_subtract = load(resource_path("test/data/swir_940_dark_subtract.png"))
landmarks = np.load(resource_path("test/data/landmarks.npy")) landmarks = np.load(resource_path("test/data/landmarks.npy"))
bounding_box = np.load(resource_path("test/data/bounding_box.npy")) bounding_box = np.load(resource_path("test/data/bounding_box.npy"))
...@@ -51,9 +52,14 @@ def test_stream(): ...@@ -51,9 +52,14 @@ def test_stream():
resource_path("config/idiap_face_calibration.json", "bob.ip.stereo"), resource_path("config/idiap_face_calibration.json", "bob.ip.stereo"),
) )
# stream for stereo and projection tests
color = f.stream("color") color = f.stream("color")
nir_left = Stream("nir_left_stereo").adjust(color) nir_left = Stream("nir_left_stereo").adjust(color)
nir_right = f.stream("nir_right_stereo").adjust(color) nir_right = f.stream("nir_right_stereo").adjust(color)
# streams for subtract tests
swir_dark = f.stream("swir")
swir_940 = f.stream("swir_940nm")
# streams for stack, normalize and warp tests
swir_1050 = f.stream("swir_1050nm") swir_1050 = f.stream("swir_1050nm")
swir_1300 = f.stream("swir_1300nm") swir_1300 = f.stream("swir_1300nm")
swir_1550 = f.stream("swir_1550nm") swir_1550 = f.stream("swir_1550nm")
...@@ -65,6 +71,10 @@ def test_stream(): ...@@ -65,6 +71,10 @@ def test_stream():
rep_color = color.reproject(nir_left, nir_right, map_3d) rep_color = color.reproject(nir_left, nir_right, map_3d)
nir_left.set_source(f) nir_left.set_source(f)
# subtract operations
swir_dark = swir_dark.adjust(color)
swir_940 = swir_940.adjust(color).subtract(swir_dark)
# warp operations # warp operations
swir_norm = swir_1550.normalize().stack(swir_1300.normalize()).stack(swir_1550.normalize()) swir_norm = swir_1550.normalize().stack(swir_1300.normalize()).stack(swir_1550.normalize())
warp_swir_norm = swir_norm.warp(color) warp_swir_norm = swir_norm.warp(color)
...@@ -85,6 +95,9 @@ def test_stream(): ...@@ -85,6 +95,9 @@ def test_stream():
assert is_close_enough(gt_depth, depth[0]) assert is_close_enough(gt_depth, depth[0])
assert is_close_enough(gt_color, rep_color[0]) assert is_close_enough(gt_color, rep_color[0])
# compare subtract results
assert np.array_equal(swir_940[0][0], gt_swir_940_dark_subtract)
# Compare warp results # Compare warp results
assert is_close_enough(warp_swir_norm[0][0], gt_warp_swir) assert is_close_enough(warp_swir_norm[0][0], gt_warp_swir)
assert is_close_enough(warp_thermal[0][0], gt_warp_thermal) assert is_close_enough(warp_thermal[0][0], gt_warp_thermal)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment