Commit 27dfc25e authored by Vincent POLLET's avatar Vincent POLLET
Browse files

Implement unit test for image format conversion

parent f8f87096
Pipeline #47317 canceled with stage
in 2 minutes and 39 seconds
......@@ -7,12 +7,14 @@ Test Units
# ==============================================================================
from bob.ip.stereo.stereo import stereo_match, reproject_image, StereoParameters
from bob.ip.stereo.camera import load_camera_config, CameraPair
from bob.ip.stereo.utils import convert_bob_to_cv, convert_cv_to_bob
from bob.io.base import load
from bob.io.image import load
from pkg_resources import resource_filename
import numpy as np
import cv2
# ==============================================================================
......@@ -27,6 +29,21 @@ def resource_path(relative_path, package="bob.ip.stereo"):
return resource_filename(package, relative_path)
# ==============================================================================
# test utils
def test_image_format_conversion():
"""Unit tests for :func:`~bob.io.stream.utils.convert_bob_to_cv` and :func:`~bob.io.stream.utils.convert_cv_to_bob`."""
bob_im = load(resource_path("test/data/color.png"))
ocv_im = cv2.imread(resource_path("test/data/color.png"))
assert np.array_equal(ocv_im, convert_bob_to_cv(bob_im))
assert np.array_equal(bob_im, convert_cv_to_bob(ocv_im))
# ==============================================================================
# Image distances functions
def sum_of_squared_absolute_difference(array1, array2):
"""Sum the squared absolute difference between the input arrays.
......@@ -59,6 +76,9 @@ def canberra_distance(array1, array2):
)
# ==============================================================================
# Image distance aggregate function
def is_close_enough(image1, image2):
"""Checks if the 2 inputs are close enough to pass the test, using different metrics.
......
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