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
e83f3503
Commit
e83f3503
authored
May 20, 2018
by
Davis King
Browse files
Fixed numpy_image and pybind11 crashing python sometimes when certain types of
conversions are attempted.
parent
86a9abe0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
dlib/python/numpy_image.h
dlib/python/numpy_image.h
+13
-3
No files found.
dlib/python/numpy_image.h
View file @
e83f3503
...
@@ -138,12 +138,21 @@ namespace dlib
...
@@ -138,12 +138,21 @@ namespace dlib
numpy_image
()
=
default
;
numpy_image
()
=
default
;
numpy_image
(
numpy_image
(
py
::
array
&
img
const
py
::
array
&
img
)
:
py
::
array_t
<
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
,
py
::
array
::
c_style
>
(
img
)
)
:
py
::
array_t
<
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
,
py
::
array
::
c_style
>
(
img
)
{
{
assert_is_image
<
pixel_type
>
(
img
);
assert_is_image
<
pixel_type
>
(
img
);
}
}
numpy_image
(
const
py
::
object
&
img
)
{
py
::
array_t
<
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
,
py
::
array
::
c_style
>
arr
=
img
.
cast
<
py
::
array
>
();
assert_is_image
<
pixel_type
>
(
arr
);
py
::
array_t
<
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
,
py
::
array
::
c_style
>::
operator
=
(
arr
);
}
numpy_image
(
numpy_image
(
const
numpy_image
&
img
const
numpy_image
&
img
)
:
py
::
array_t
<
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
,
py
::
array
::
c_style
>
(
img
)
)
:
py
::
array_t
<
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
,
py
::
array
::
c_style
>
(
img
)
...
@@ -154,8 +163,9 @@ namespace dlib
...
@@ -154,8 +163,9 @@ namespace dlib
const
py
::
object
&
rhs
const
py
::
object
&
rhs
)
)
{
{
assert_is_image
<
pixel_type
>
(
rhs
);
py
::
array_t
<
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
,
py
::
array
::
c_style
>
arr
=
rhs
.
cast
<
py
::
array
>
();
*
this
=
rhs
.
cast
<
py
::
array
>
();
assert_is_image
<
pixel_type
>
(
arr
);
py
::
array_t
<
typename
pixel_traits
<
pixel_type
>::
basic_pixel_type
,
py
::
array
::
c_style
>::
operator
=
(
arr
);
return
*
this
;
return
*
this
;
}
}
...
...
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