Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bob.io.stream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.io.stream
Commits
78c10e2a
Commit
78c10e2a
authored
4 years ago
by
Vincent POLLET
Browse files
Options
Downloads
Patches
Plain Diff
Remove image conversion from utils and use those from bob.io.image.utils
parent
53d7d391
No related branches found
No related tags found
1 merge request
!14
Remove image conversion from utils and use those from bob.io.image.utils
Pipeline
#47327
failed
4 years ago
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bob/io/stream/stream_image_filters.py
+4
-2
4 additions, 2 deletions
bob/io/stream/stream_image_filters.py
bob/io/stream/test/test_utils.py
+1
-13
1 addition, 13 deletions
bob/io/stream/test/test_utils.py
bob/io/stream/utils.py
+0
-58
0 additions, 58 deletions
bob/io/stream/utils.py
with
5 additions
and
73 deletions
bob/io/stream/stream_image_filters.py
+
4
−
2
View file @
78c10e2a
...
...
@@ -20,10 +20,12 @@ import numpy as np
from
skimage
import
transform
import
cv2
as
cv
from
bob.io.image.utils
import
opencvbgr_to_bob
from
bob.ip.stereo
import
StereoParameters
from
bob.ip.stereo
import
stereo_match
,
reproject_image
,
CameraPair
from
.utils
import
convert_cv_to_bob
,
StreamArray
from
.utils
import
StreamArray
from
.stream
import
stream_filter
,
StreamFilter
...
...
@@ -161,7 +163,7 @@ class StreamColorMap(StreamFilter):
"
hsv
"
:
cv
.
COLORMAP_HSV
,
}
data
=
cv
.
applyColorMap
(
data
,
maps
[
self
.
colormap
])
data
=
convert_cv
_to_bob
(
data
)
data
=
opencvbgr
_to_bob
(
data
)
return
data
else
:
raise
ValueError
(
"
Can not convert multi-channel streams. Parent number of channels:
"
+
str
(
data
.
shape
[
0
]))
...
...
This diff is collapsed.
Click to expand it.
bob/io/stream/test/test_utils.py
+
1
−
13
View file @
78c10e2a
...
...
@@ -10,22 +10,10 @@ import cv2
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
from
bob.io.stream.utils
import
get_axis_size
,
get_index_list
,
rotate_data
# ==============================================================================
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
():
"""
Unit tests for :func:`~bob.io.stream.utils.rotate_data`.
"""
...
...
This diff is collapsed.
Click to expand it.
bob/io/stream/utils.py
+
0
−
58
View file @
78c10e2a
...
...
@@ -2,64 +2,6 @@ import numpy as np
import
cv2
as
cv
def
convert_bob_to_cv
(
img
):
"""
Convert image from Bob
'
s <RGB, h, w> format to OpenCV
'
s <h, w, BGR> format.
Parameters
----------
img : :obj:`numpy.ndarray`
Image in Bob
'
s format <RGB, h, w>.
Returns
-------
:obj:`numpy.ndarray`
Image in OpenCV
'
s format <h, w, BGR>.
Raises
------
ValueError
If the input image has the wrong number of dimensions. (Must be 3).
ValueError
If the input image does not have 3 channels in first dimension.
"""
if
len
(
img
.
shape
)
!=
3
:
raise
ValueError
(
"
Expected image to be 3D object, but got shape
"
+
str
(
img
.
shape
))
if
img
.
shape
[
0
]
!=
3
:
raise
ValueError
(
"
Expected image to have 3 color channels, but got
"
+
str
(
img
.
shape
[
0
])
+
"
channels.
"
)
img
=
np
.
moveaxis
(
img
,
0
,
2
)
img
=
np
.
flip
(
img
,
axis
=
2
)
return
img
def
convert_cv_to_bob
(
img
):
"""
Convert image from OpenCV
'
s <h, w, BGR> format to Bob
'
s <RGB, h, w> format.
Parameters
----------
img : :obj:`numpy.ndarray`
Image in OpenCV
'
s <h, w, BGR> format.
Returns
-------
:obj:`numpy.ndarray`
Image in Bob
'
s <RGB, h, w> format.
Raises
------
ValueError
If the input image has the wrong number of dimension. (Must be 3).
ValueError
If the input image does not have 3 channels in the last dimension.
"""
if
len
(
img
.
shape
)
!=
3
:
raise
ValueError
(
"
Expected image to have 3 dimension, but got shape
"
+
str
(
img
.
shape
))
if
img
.
shape
[
2
]
!=
3
:
raise
ValueError
(
"
Expected image to have 3 color channels, but got
"
+
str
(
img
.
shape
[
2
])
+
"
channels.
"
)
img
=
np
.
moveaxis
(
img
,
2
,
0
)
img
=
np
.
flip
(
img
,
axis
=
0
)
return
img
def
rotate_data
(
data
,
angle
):
"""
Rotate the `data` array by `angle`, where `angle` is a multiple of a square angle.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment