Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
06ce2078
Commit
06ce2078
authored
May 19, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed numpy_image not working correctly for grayscale images.
parent
2b55b996
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
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
!*/
{
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
()
&&
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
{
using
basic_pixel_type
=
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
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
:
...
...
@@ -256,7 +258,7 @@ namespace dlib
assert_correct_num_channels_in_image
<
pixel_type
>
(
img
);
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
)));
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
)));
...
...
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