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

Merge branch 'fix_ocv_bob_image_conversion' into 'master'

Fix ocv bob image conversion

See merge request !13
parents 42629259 17f55eb4
No related branches found
No related tags found
1 merge request!13Fix ocv bob image conversion
Pipeline #47313 canceled
No preview for this file type
No preview for this file type
bob/io/stream/test/data/reprojection_color.png

2.44 MiB | W: | H:

bob/io/stream/test/data/reprojection_color.png

3.15 MiB | W: | H:

bob/io/stream/test/data/reprojection_color.png
bob/io/stream/test/data/reprojection_color.png
bob/io/stream/test/data/reprojection_color.png
bob/io/stream/test/data/reprojection_color.png
  • 2-up
  • Swipe
  • Onion skin
bob/io/stream/test/data/reprojection_depth.png

355 KiB | W: | H:

bob/io/stream/test/data/reprojection_depth.png

374 KiB | W: | H:

bob/io/stream/test/data/reprojection_depth.png
bob/io/stream/test/data/reprojection_depth.png
bob/io/stream/test/data/reprojection_depth.png
bob/io/stream/test/data/reprojection_depth.png
  • 2-up
  • Swipe
  • Onion skin
bob/io/stream/test/data/swir_940_dark_subtract.png

429 KiB | W: | H:

bob/io/stream/test/data/swir_940_dark_subtract.png

407 KiB | W: | H:

bob/io/stream/test/data/swir_940_dark_subtract.png
bob/io/stream/test/data/swir_940_dark_subtract.png
bob/io/stream/test/data/swir_940_dark_subtract.png
bob/io/stream/test/data/swir_940_dark_subtract.png
  • 2-up
  • Swipe
  • Onion skin
bob/io/stream/test/data/warp_swir_norm.png

606 KiB | W: | H:

bob/io/stream/test/data/warp_swir_norm.png

654 KiB | W: | H:

bob/io/stream/test/data/warp_swir_norm.png
bob/io/stream/test/data/warp_swir_norm.png
bob/io/stream/test/data/warp_swir_norm.png
bob/io/stream/test/data/warp_swir_norm.png
  • 2-up
  • Swipe
  • Onion skin
bob/io/stream/test/data/warp_thermal.png

301 KiB | W: | H:

bob/io/stream/test/data/warp_thermal.png

355 KiB | W: | H:

bob/io/stream/test/data/warp_thermal.png
bob/io/stream/test/data/warp_thermal.png
bob/io/stream/test/data/warp_thermal.png
bob/io/stream/test/data/warp_thermal.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -6,12 +6,26 @@ Test Units of utils functions. ...@@ -6,12 +6,26 @@ Test Units of utils functions.
""" """
# ============================================================================== # ==============================================================================
import numpy as np import numpy as np
import cv2
from bob.io.stream.utils import get_axis_size, get_index_list, rotate_data from bob.io.image import load
from bob.io.stream.utils import get_axis_size, get_index_list, rotate_data, convert_bob_to_cv, convert_cv_to_bob
from bob.io.stream.test.test import resource_path
# ============================================================================== # ==============================================================================
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/reprojection_color.png"))
ocv_im = cv2.imread(resource_path("test/data/reprojection_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))
def test_rotate_data(): def test_rotate_data():
"""Unit tests for :func:`~bob.io.stream.utils.rotate_data`.""" """Unit tests for :func:`~bob.io.stream.utils.rotate_data`."""
......
...@@ -26,7 +26,7 @@ def convert_bob_to_cv(img): ...@@ -26,7 +26,7 @@ def convert_bob_to_cv(img):
raise ValueError("Expected image to be 3D object, but got shape " + str(img.shape)) raise ValueError("Expected image to be 3D object, but got shape " + str(img.shape))
if img.shape[0] != 3: if img.shape[0] != 3:
raise ValueError("Expected image to have 3 color channels, but got " + str(img.shape[0]) + " channels.") raise ValueError("Expected image to have 3 color channels, but got " + str(img.shape[0]) + " channels.")
img = np.rollaxis(img, 2) img = np.moveaxis(img, 0, 2)
img = np.flip(img, axis=2) img = np.flip(img, axis=2)
return img return img
...@@ -55,7 +55,7 @@ def convert_cv_to_bob(img): ...@@ -55,7 +55,7 @@ def convert_cv_to_bob(img):
raise ValueError("Expected image to have 3 dimension, but got shape " + str(img.shape)) raise ValueError("Expected image to have 3 dimension, but got shape " + str(img.shape))
if img.shape[2] != 3: if img.shape[2] != 3:
raise ValueError("Expected image to have 3 color channels, but got " + str(img.shape[2]) + " channels.") raise ValueError("Expected image to have 3 color channels, but got " + str(img.shape[2]) + " channels.")
img = np.rollaxis(img, 2) img = np.moveaxis(img, 2, 0)
img = np.flip(img, axis=0) img = np.flip(img, axis=0)
return img return img
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment