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
a190a1c2
Commit
a190a1c2
authored
May 20, 2018
by
Davis King
Browse files
Added equalize_histogram() and resize_image() to the Python API.
parent
1df5227e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
tools/python/CMakeLists.txt
tools/python/CMakeLists.txt
+1
-0
tools/python/src/dlib.cpp
tools/python/src/dlib.cpp
+2
-0
tools/python/src/image2.cpp
tools/python/src/image2.cpp
+64
-0
No files found.
tools/python/CMakeLists.txt
View file @
a190a1c2
...
...
@@ -61,6 +61,7 @@ set(python_srcs
src/sequence_segmenter.cpp
src/svm_struct.cpp
src/image.cpp
src/image2.cpp
src/rectangles.cpp
src/object_detection.cpp
src/shape_predictor.cpp
...
...
tools/python/src/dlib.cpp
View file @
a190a1c2
...
...
@@ -19,6 +19,7 @@ void bind_cca(py::module& m);
void
bind_sequence_segmenter
(
py
::
module
&
m
);
void
bind_svm_struct
(
py
::
module
&
m
);
void
bind_image_classes
(
py
::
module
&
m
);
void
bind_image_classes2
(
py
::
module
&
m
);
void
bind_rectangles
(
py
::
module
&
m
);
void
bind_object_detection
(
py
::
module
&
m
);
void
bind_shape_predictors
(
py
::
module
&
m
);
...
...
@@ -91,6 +92,7 @@ PYBIND11_MODULE(dlib, m)
bind_sequence_segmenter
(
m
);
bind_svm_struct
(
m
);
bind_image_classes
(
m
);
bind_image_classes2
(
m
);
bind_rectangles
(
m
);
bind_object_detection
(
m
);
bind_shape_predictors
(
m
);
...
...
tools/python/src/image2.cpp
0 → 100644
View file @
a190a1c2
#include "opaque_types.h"
#include <dlib/python.h>
#include "dlib/pixel.h"
#include <dlib/image_transforms.h>
#include <dlib/image_processing.h>
using
namespace
dlib
;
using
namespace
std
;
namespace
py
=
pybind11
;
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
numpy_image
<
T
>
py_resize_image
(
const
numpy_image
<
T
>&
img
,
unsigned
long
rows
,
unsigned
long
cols
)
{
numpy_image
<
T
>
out
;
set_image_size
(
out
,
rows
,
cols
);
resize_image
(
img
,
out
);
return
out
;
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
numpy_image
<
T
>
py_equalize_histogram
(
const
numpy_image
<
T
>&
img
)
{
numpy_image
<
T
>
out
;
equalize_histogram
(
img
,
out
);
return
out
;
}
// ----------------------------------------------------------------------------------------
void
bind_image_classes2
(
py
::
module
&
m
)
{
const
char
*
docs
=
"Resizes img, using bilinear interpolation, to have the indicated number of rows and columns."
;
m
.
def
(
"resize_image"
,
&
py_resize_image
<
uint8_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
uint16_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
uint32_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
uint64_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
int8_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
int16_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
int32_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
int64_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
float
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
double
>
,
docs
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
docs
=
"Returns a histogram equalized version of img."
;
m
.
def
(
"equalize_histogram"
,
&
py_equalize_histogram
<
uint8_t
>
,
py
::
arg
(
"img"
));
m
.
def
(
"equalize_histogram"
,
&
py_equalize_histogram
<
uint16_t
>
,
docs
,
py
::
arg
(
"img"
));
}
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