Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
06ce2078
"examples/git@developer.sourcefind.cn:OpenDAS/fairseq.git" did not exist on "1e55bbdb385cccc72c7ac0d305ffd120ded7e1b6"
Commit
06ce2078
authored
May 18, 2018
by
Davis King
Browse files
Fixed numpy_image not working correctly for grayscale images.
parent
2b55b996
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
dlib/python/numpy_image.h
dlib/python/numpy_image.h
+6
-4
No files found.
dlib/python/numpy_image.h
View file @
06ce2078
...
@@ -33,11 +33,10 @@ namespace dlib
...
@@ -33,11 +33,10 @@ namespace dlib
!*/
!*/
{
{
using
basic_pixel_type
=
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
using
basic_pixel_type
=
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
constexpr
size_t
channels
=
pixel_traits
<
pixel_type
>::
num
;
return
obj
.
dtype
().
kind
()
==
py
::
dtype
::
of
<
basic_pixel_type
>
().
kind
()
&&
return
obj
.
dtype
().
kind
()
==
py
::
dtype
::
of
<
basic_pixel_type
>
().
kind
()
&&
obj
.
itemsize
()
==
sizeof
(
basic_pixel_type
)
&&
obj
.
itemsize
()
==
sizeof
(
basic_pixel_type
)
&&
obj
.
ndim
()
==
pixel_traits
<
pixel_type
>::
num
;
((
pixel_traits
<
pixel_type
>::
num
==
1
)
?
(
obj
.
ndim
()
==
2
)
:
(
obj
.
ndim
()
==
3
))
;
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -170,7 +169,10 @@ namespace dlib
...
@@ -170,7 +169,10 @@ namespace dlib
{
{
using
basic_pixel_type
=
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
using
basic_pixel_type
=
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
constexpr
size_t
channels
=
pixel_traits
<
pixel_type
>::
num
;
constexpr
size_t
channels
=
pixel_traits
<
pixel_type
>::
num
;
*
this
=
py
::
array_t
<
basic_pixel_type
>
({
rows
,
cols
,
channels
});
if
(
channels
!=
1
)
*
this
=
py
::
array_t
<
basic_pixel_type
>
({
rows
,
cols
,
channels
});
else
*
this
=
py
::
array_t
<
basic_pixel_type
>
({
rows
,
cols
});
}
}
private:
private:
...
@@ -256,7 +258,7 @@ namespace dlib
...
@@ -256,7 +258,7 @@ namespace dlib
assert_correct_num_channels_in_image
<
pixel_type
>
(
img
);
assert_correct_num_channels_in_image
<
pixel_type
>
(
img
);
using
basic_pixel_type
=
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
using
basic_pixel_type
=
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
if
(
img
.
strides
(
2
)
!=
sizeof
(
basic_pixel_type
))
if
(
img
.
ndim
()
==
3
&&
img
.
strides
(
2
)
!=
sizeof
(
basic_pixel_type
))
throw
dlib
::
error
(
"The stride of the 3rd dimension (the channel dimension) of the numpy array must be "
+
std
::
to_string
(
sizeof
(
basic_pixel_type
)));
throw
dlib
::
error
(
"The stride of the 3rd dimension (the channel dimension) of the numpy array must be "
+
std
::
to_string
(
sizeof
(
basic_pixel_type
)));
if
(
img
.
strides
(
1
)
!=
sizeof
(
pixel_type
))
if
(
img
.
strides
(
1
)
!=
sizeof
(
pixel_type
))
throw
dlib
::
error
(
"The stride of the 2nd dimension (the columns dimension) of the numpy array must be "
+
std
::
to_string
(
sizeof
(
pixel_type
)));
throw
dlib
::
error
(
"The stride of the 2nd dimension (the columns dimension) of the numpy array must be "
+
std
::
to_string
(
sizeof
(
pixel_type
)));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment