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
951fdd00
Unverified
Commit
951fdd00
authored
Jul 27, 2021
by
Adrià Arrufat
Committed by
GitHub
Jul 26, 2021
Browse files
return the projective transform in extract_image_4points (#2395)
parent
b850f0e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
dlib/image_transforms/interpolation.h
dlib/image_transforms/interpolation.h
+5
-4
dlib/image_transforms/interpolation_abstract.h
dlib/image_transforms/interpolation_abstract.h
+6
-2
No files found.
dlib/image_transforms/interpolation.h
View file @
951fdd00
...
@@ -2118,7 +2118,7 @@ namespace dlib
...
@@ -2118,7 +2118,7 @@ namespace dlib
template
<
template
<
typename
image_type
typename
image_type
>
>
v
oi
d
extract_image_4points
(
p
oi
nt_transform_projective
extract_image_4points
(
const
image_type
&
img_
,
const
image_type
&
img_
,
image_type
&
out_
,
image_type
&
out_
,
const
std
::
array
<
dpoint
,
4
>&
pts
const
std
::
array
<
dpoint
,
4
>&
pts
...
@@ -2127,7 +2127,7 @@ namespace dlib
...
@@ -2127,7 +2127,7 @@ namespace dlib
const_image_view
<
image_type
>
img
(
img_
);
const_image_view
<
image_type
>
img
(
img_
);
image_view
<
image_type
>
out
(
out_
);
image_view
<
image_type
>
out
(
out_
);
if
(
out
.
size
()
==
0
)
if
(
out
.
size
()
==
0
)
return
;
return
point_transform_projective
()
;
drectangle
bounding_box
;
drectangle
bounding_box
;
for
(
auto
&
p
:
pts
)
for
(
auto
&
p
:
pts
)
...
@@ -2160,18 +2160,19 @@ namespace dlib
...
@@ -2160,18 +2160,19 @@ namespace dlib
auto
tform
=
find_projective_transform
(
from_points
,
to_points
);
auto
tform
=
find_projective_transform
(
from_points
,
to_points
);
transform_image
(
img_
,
out_
,
interpolate_bilinear
(),
tform
);
transform_image
(
img_
,
out_
,
interpolate_bilinear
(),
tform
);
return
inv
(
tform
);
}
}
template
<
template
<
typename
image_type
typename
image_type
>
>
v
oi
d
extract_image_4points
(
p
oi
nt_transform_projective
extract_image_4points
(
const
image_type
&
img
,
const
image_type
&
img
,
image_type
&
out
,
image_type
&
out
,
const
std
::
array
<
line
,
4
>&
lines
const
std
::
array
<
line
,
4
>&
lines
)
)
{
{
extract_image_4points
(
img
,
out
,
find_convex_quadrilateral
(
lines
));
return
extract_image_4points
(
img
,
out
,
find_convex_quadrilateral
(
lines
));
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/image_transforms/interpolation_abstract.h
View file @
951fdd00
...
@@ -1542,7 +1542,7 @@ namespace dlib
...
@@ -1542,7 +1542,7 @@ namespace dlib
template
<
template
<
typename
image_type
typename
image_type
>
>
v
oi
d
extract_image_4points
(
p
oi
nt_transform_projective
extract_image_4points
(
const
image_type
&
img
,
const
image_type
&
img
,
image_type
&
out
,
image_type
&
out
,
const
std
::
array
<
dpoint
,
4
>&
pts
const
std
::
array
<
dpoint
,
4
>&
pts
...
@@ -1564,12 +1564,14 @@ namespace dlib
...
@@ -1564,12 +1564,14 @@ namespace dlib
left corner, upper right corner to upper right corner, etc.).
left corner, upper right corner to upper right corner, etc.).
- #out.nr() == out.nr() && #out.nc() == out.nc().
- #out.nr() == out.nr() && #out.nc() == out.nc().
I.e. out should already be sized to whatever size you want it to be.
I.e. out should already be sized to whatever size you want it to be.
- Returns a transformation object that maps points in img into their
corresponding location in #out.
!*/
!*/
template
<
template
<
typename
image_type
typename
image_type
>
>
v
oi
d
extract_image_4points
(
p
oi
nt_transform_projective
extract_image_4points
(
const
image_type
&
img
,
const
image_type
&
img
,
image_type
&
out
,
image_type
&
out
,
const
std
::
array
<
line
,
4
>&
lines
const
std
::
array
<
line
,
4
>&
lines
...
@@ -1584,6 +1586,8 @@ namespace dlib
...
@@ -1584,6 +1586,8 @@ namespace dlib
convex quadrilateral and uses them in a call to the version of
convex quadrilateral and uses them in a call to the version of
extract_image_4points() defined above. i.e. extract_image_4points(img, out,
extract_image_4points() defined above. i.e. extract_image_4points(img, out,
intersections_between_lines)
intersections_between_lines)
- Returns a transformation object that maps points in img into their
corresponding location in #out.
throws
throws
- no_convex_quadrilateral: this is thrown if you can't make a convex
- no_convex_quadrilateral: this is thrown if you can't make a convex
quadrilateral out of the given lines.
quadrilateral out of the given lines.
...
...
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