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
89ffae61
Commit
89ffae61
authored
May 24, 2018
by
Davis King
Browse files
Added load_grayscale_image() to the Python API
parent
840bb5bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
tools/python/src/numpy_returns.cpp
tools/python/src/numpy_returns.cpp
+15
-3
No files found.
tools/python/src/numpy_returns.cpp
View file @
89ffae61
...
@@ -20,6 +20,13 @@ numpy_image<rgb_pixel> load_rgb_image (const std::string &path)
...
@@ -20,6 +20,13 @@ numpy_image<rgb_pixel> load_rgb_image (const std::string &path)
return
img
;
return
img
;
}
}
numpy_image
<
unsigned
char
>
load_grayscale_image
(
const
std
::
string
&
path
)
{
numpy_image
<
unsigned
char
>
img
;
load_image
(
img
,
path
);
return
img
;
}
bool
has_ending
(
std
::
string
const
full_string
,
std
::
string
const
&
ending
)
{
bool
has_ending
(
std
::
string
const
full_string
,
std
::
string
const
&
ending
)
{
if
(
full_string
.
length
()
>=
ending
.
length
())
{
if
(
full_string
.
length
()
>=
ending
.
length
())
{
return
(
0
==
full_string
.
compare
(
full_string
.
length
()
-
ending
.
length
(),
ending
.
length
(),
ending
));
return
(
0
==
full_string
.
compare
(
full_string
.
length
()
-
ending
.
length
(),
ending
.
length
(),
ending
));
...
@@ -121,16 +128,21 @@ void bind_numpy_returns(py::module &m)
...
@@ -121,16 +128,21 @@ void bind_numpy_returns(py::module &m)
{
{
m
.
def
(
"load_rgb_image"
,
&
load_rgb_image
,
m
.
def
(
"load_rgb_image"
,
&
load_rgb_image
,
"Takes a path and returns a numpy array (RGB) containing the image"
,
"Takes a path and returns a numpy array (RGB) containing the image"
,
py
::
arg
(
"path"
)
py
::
arg
(
"filename"
)
);
m
.
def
(
"load_grayscale_image"
,
&
load_grayscale_image
,
"Takes a path and returns a numpy array containing the image, as an 8bit grayscale image."
,
py
::
arg
(
"filename"
)
);
);
m
.
def
(
"save_image"
,
&
save_image
<
rgb_pixel
>
,
m
.
def
(
"save_image"
,
&
save_image
<
rgb_pixel
>
,
"Saves the given image to the specified path. Determines the file type from the file extension specified in the path"
,
"Saves the given image to the specified path. Determines the file type from the file extension specified in the path"
,
py
::
arg
(
"img"
),
py
::
arg
(
"
path
"
)
py
::
arg
(
"img"
),
py
::
arg
(
"
filename
"
)
);
);
m
.
def
(
"save_image"
,
&
save_image
<
unsigned
char
>
,
m
.
def
(
"save_image"
,
&
save_image
<
unsigned
char
>
,
"Saves the given image to the specified path. Determines the file type from the file extension specified in the path"
,
"Saves the given image to the specified path. Determines the file type from the file extension specified in the path"
,
py
::
arg
(
"img"
),
py
::
arg
(
"
path
"
)
py
::
arg
(
"img"
),
py
::
arg
(
"
filename
"
)
);
);
m
.
def
(
"jitter_image"
,
&
get_jitter_images
,
m
.
def
(
"jitter_image"
,
&
get_jitter_images
,
...
...
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