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
027cf643
Commit
027cf643
authored
May 25, 2018
by
Davis King
Browse files
Added an assign_image() that takes py::array as source image.
parent
bd2e0bc3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
dlib/python/numpy_image.h
dlib/python/numpy_image.h
+25
-0
No files found.
dlib/python/numpy_image.h
View file @
027cf643
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
#include <memory>
#include <memory>
#include <pybind11/numpy.h>
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
#include <pybind11/pybind11.h>
#include <dlib/image_transforms/assign_image.h>
#include <stdint.h>
namespace
py
=
pybind11
;
namespace
py
=
pybind11
;
...
@@ -246,6 +248,29 @@ namespace dlib
...
@@ -246,6 +248,29 @@ namespace dlib
};
};
// ----------------------------------------------------------------------------------------
template
<
typename
pixel_type
>
void
assign_image
(
numpy_image
<
pixel_type
>&
dest
,
const
py
::
array
&
src
)
{
if
(
is_image
<
pixel_type
>
(
src
))
dest
=
src
;
else
if
(
is_image
<
uint8_t
>
(
src
))
assign_image
(
dest
,
numpy_image
<
uint8_t
>
(
src
));
else
if
(
is_image
<
uint16_t
>
(
src
))
assign_image
(
dest
,
numpy_image
<
uint16_t
>
(
src
));
else
if
(
is_image
<
uint32_t
>
(
src
))
assign_image
(
dest
,
numpy_image
<
uint32_t
>
(
src
));
else
if
(
is_image
<
uint64_t
>
(
src
))
assign_image
(
dest
,
numpy_image
<
uint64_t
>
(
src
));
else
if
(
is_image
<
int8_t
>
(
src
))
assign_image
(
dest
,
numpy_image
<
int8_t
>
(
src
));
else
if
(
is_image
<
int16_t
>
(
src
))
assign_image
(
dest
,
numpy_image
<
int16_t
>
(
src
));
else
if
(
is_image
<
int32_t
>
(
src
))
assign_image
(
dest
,
numpy_image
<
int32_t
>
(
src
));
else
if
(
is_image
<
int64_t
>
(
src
))
assign_image
(
dest
,
numpy_image
<
int64_t
>
(
src
));
else
if
(
is_image
<
float
>
(
src
))
assign_image
(
dest
,
numpy_image
<
float
>
(
src
));
else
if
(
is_image
<
double
>
(
src
))
assign_image
(
dest
,
numpy_image
<
double
>
(
src
));
else
if
(
is_image
<
rgb_pixel
>
(
src
))
assign_image
(
dest
,
numpy_image
<
rgb_pixel
>
(
src
));
else
DLIB_CASSERT
(
false
,
"Unsupported pixel type used in assign_image()."
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// BORING IMPLEMENTATION STUFF
// BORING IMPLEMENTATION STUFF
...
...
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