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
52e7ab68
Commit
52e7ab68
authored
May 20, 2018
by
Davis King
Browse files
Made image_window use numpy_image explicitly so it benefits from numpy_image's
automatic binding.
parent
cafd6a0a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
tools/python/src/gui.cpp
tools/python/src/gui.cpp
+16
-12
No files found.
tools/python/src/gui.cpp
View file @
52e7ab68
...
@@ -33,17 +33,13 @@ void image_window_set_image_simple_detector_py (
...
@@ -33,17 +33,13 @@ void image_window_set_image_simple_detector_py (
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
image_window_set_image
(
void
image_window_set_image
(
image_window
&
win
,
image_window
&
win
,
py
::
array
img
const
numpy_image
<
T
>&
img
)
)
{
{
if
(
is_image
<
unsigned
char
>
(
img
))
win
.
set_image
(
img
);
return
win
.
set_image
(
numpy_image
<
unsigned
char
>
(
img
));
else
if
(
is_image
<
rgb_pixel
>
(
img
))
return
win
.
set_image
(
numpy_image
<
rgb_pixel
>
(
img
));
else
throw
dlib
::
error
(
"Unsupported image type, must be 8bit gray or RGB image."
);
}
}
void
add_overlay_rect
(
void
add_overlay_rect
(
...
@@ -74,14 +70,16 @@ void add_overlay_parts (
...
@@ -74,14 +70,16 @@ void add_overlay_parts (
win
.
add_overlay
(
render_face_detections
(
detection
,
color
));
win
.
add_overlay
(
render_face_detections
(
detection
,
color
));
}
}
std
::
shared_ptr
<
image_window
>
make_image_window_from_image
(
py
::
array
img
)
template
<
typename
T
>
std
::
shared_ptr
<
image_window
>
make_image_window_from_image
(
const
numpy_image
<
T
>&
img
)
{
{
auto
win
=
std
::
make_shared
<
image_window
>
();
auto
win
=
std
::
make_shared
<
image_window
>
();
image_window_set_image
(
*
win
,
img
);
image_window_set_image
(
*
win
,
img
);
return
win
;
return
win
;
}
}
std
::
shared_ptr
<
image_window
>
make_image_window_from_image_and_title
(
py
::
array
img
,
const
string
&
title
)
template
<
typename
T
>
std
::
shared_ptr
<
image_window
>
make_image_window_from_image_and_title
(
const
numpy_image
<
T
>&
img
,
const
string
&
title
)
{
{
auto
win
=
std
::
make_shared
<
image_window
>
();
auto
win
=
std
::
make_shared
<
image_window
>
();
image_window_set_image
(
*
win
,
img
);
image_window_set_image
(
*
win
,
img
);
...
@@ -100,15 +98,21 @@ void bind_gui(py::module& m)
...
@@ -100,15 +98,21 @@ void bind_gui(py::module& m)
py
::
class_
<
type
,
std
::
shared_ptr
<
type
>>
(
m
,
"image_window"
,
py
::
class_
<
type
,
std
::
shared_ptr
<
type
>>
(
m
,
"image_window"
,
"This is a GUI window capable of showing images on the screen."
)
"This is a GUI window capable of showing images on the screen."
)
.
def
(
py
::
init
())
.
def
(
py
::
init
())
.
def
(
py
::
init
(
&
make_image_window_from_image
),
.
def
(
py
::
init
(
&
make_image_window_from_image
<
uint8_t
>
),
"Create an image window that displays the given numpy image."
)
"Create an image window that displays the given numpy image."
)
.
def
(
py
::
init
(
&
make_image_window_from_image_and_title
),
.
def
(
py
::
init
(
&
make_image_window_from_image
<
rgb_pixel
>
),
"Create an image window that displays the given numpy image."
)
.
def
(
py
::
init
(
&
make_image_window_from_image_and_title
<
uint8_t
>
),
"Create an image window that displays the given numpy image and also has the given title."
)
.
def
(
py
::
init
(
&
make_image_window_from_image_and_title
<
rgb_pixel
>
),
"Create an image window that displays the given numpy image and also has the given title."
)
"Create an image window that displays the given numpy image and also has the given title."
)
.
def
(
"set_image"
,
image_window_set_image_simple_detector_py
,
py
::
arg
(
"detector"
),
.
def
(
"set_image"
,
image_window_set_image_simple_detector_py
,
py
::
arg
(
"detector"
),
"Make the image_window display the given HOG detector's filters."
)
"Make the image_window display the given HOG detector's filters."
)
.
def
(
"set_image"
,
image_window_set_image_fhog_detector
,
py
::
arg
(
"detector"
),
.
def
(
"set_image"
,
image_window_set_image_fhog_detector
,
py
::
arg
(
"detector"
),
"Make the image_window display the given HOG detector's filters."
)
"Make the image_window display the given HOG detector's filters."
)
.
def
(
"set_image"
,
image_window_set_image
,
py
::
arg
(
"image"
),
.
def
(
"set_image"
,
image_window_set_image
<
uint8_t
>
,
py
::
arg
(
"image"
),
"Make the image_window display the given image."
)
.
def
(
"set_image"
,
image_window_set_image
<
rgb_pixel
>
,
py
::
arg
(
"image"
),
"Make the image_window display the given image."
)
"Make the image_window display the given image."
)
.
def
(
"set_title"
,
(
set_title_funct
)
&
type
::
set_title
,
py
::
arg
(
"title"
),
.
def
(
"set_title"
,
(
set_title_funct
)
&
type
::
set_title
,
py
::
arg
(
"title"
),
"Set the title of the window to the given value."
)
"Set the title of the window to the given value."
)
...
...
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