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
f917f5e5
Commit
f917f5e5
authored
May 20, 2018
by
Davis King
Browse files
Made the numpy_image capable of binding to tuples that contain a valid image as
their first element.
parent
1619725f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
dlib/python/numpy_image.h
dlib/python/numpy_image.h
+9
-0
No files found.
dlib/python/numpy_image.h
View file @
f917f5e5
...
...
@@ -358,6 +358,15 @@ namespace pybind11
using
type
=
dlib
::
numpy_image
<
pixel_type
>
;
bool
load
(
handle
src
,
bool
convert
)
{
// If passed a tuple where the first element of the tuple is a valid
// numpy_image then bind the numpy_image to that element of the tuple.
// We do this because there is a pattern of returning an image and some
// associated metadata. This allows the returned tuple from such functions
// to also be treated as an image without needing to unpack the first
// argument.
if
(
PyTuple_Check
(
src
.
ptr
())
&&
PyTuple_Size
(
src
.
ptr
())
>=
1
)
src
=
reinterpret_borrow
<
py
::
tuple
>
(
src
)[
0
];
if
(
!
type
::
check_
(
src
))
return
false
;
// stash the output of ensure into a temp variable since assigning it to
...
...
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