Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
39a13298
Commit
39a13298
authored
May 23, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a version of transform_image() that works with projective transforms to
the Python API.
parent
a67bdd8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
image2.cpp
tools/python/src/image2.cpp
+58
-0
No files found.
tools/python/src/image2.cpp
View file @
39a13298
...
@@ -519,6 +519,26 @@ std::vector<point> py_remove_incoherent_edge_pixels (
...
@@ -519,6 +519,26 @@ std::vector<point> py_remove_incoherent_edge_pixels (
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
numpy_image
<
T
>
py_transform_image
(
const
numpy_image
<
T
>&
img
,
const
point_transform_projective
&
map_point
,
long
rows
,
long
columns
)
{
DLIB_CASSERT
(
rows
>
0
&&
columns
>
0
,
"The requested output image dimensions are invalid."
);
numpy_image
<
T
>
out_
;
image_view
<
numpy_image
<
T
>>
out
(
out_
);
out
.
set_size
(
rows
,
columns
);
transform_image
(
img
,
out_
,
interpolate_bilinear
(),
map_point
);
return
out_
;
}
// ----------------------------------------------------------------------------------------
void
bind_image_classes2
(
py
::
module
&
m
)
void
bind_image_classes2
(
py
::
module
&
m
)
{
{
...
@@ -535,6 +555,7 @@ void bind_image_classes2(py::module& m)
...
@@ -535,6 +555,7 @@ void bind_image_classes2(py::module& m)
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
<
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
<
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"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
double
>
,
docs
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
m
.
def
(
"resize_image"
,
&
py_resize_image
<
rgb_pixel
>
,
docs
,
py
::
arg
(
"img"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"cols"
));
docs
=
"Returns a histogram equalized version of img."
;
docs
=
"Returns a histogram equalized version of img."
;
...
@@ -603,6 +624,43 @@ ensures \n\
...
@@ -603,6 +624,43 @@ ensures \n\
- PTS is just line with some elements removed.
- PTS is just line with some elements removed.
!*/
!*/
m
.
def
(
"transform_image"
,
&
py_transform_image
<
uint8_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
uint16_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
uint32_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
uint64_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
int8_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
int16_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
int32_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
int64_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
float
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
double
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
));
m
.
def
(
"transform_image"
,
&
py_transform_image
<
rgb_pixel
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"map_point"
),
py
::
arg
(
"rows"
),
py
::
arg
(
"columns"
),
"requires
\n
\
- rows > 0
\n
\
- columns > 0
\n
\
ensures
\n
\
- Returns an image that is the given rows by columns in size and contains a
\n
\
transformed part of img. To do this, we interpret map_point as a mapping
\n
\
from pixels in the returned image to pixels in the input img. transform_image()
\n
\
uses this mapping and bilinear interpolation to fill the output image with an
\n
\
interpolated copy of img.
\n
\
- Any locations in the output image that map to pixels outside img are set to 0."
/*!
requires
- rows > 0
- columns > 0
ensures
- Returns an image that is the given rows by columns in size and contains a
transformed part of img. To do this, we interpret map_point as a mapping
from pixels in the returned image to pixels in the input img. transform_image()
uses this mapping and bilinear interpolation to fill the output image with an
interpolated copy of img.
- Any locations in the output image that map to pixels outside img are set to 0.
!*/
);
}
}
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