Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
124c4825
Commit
124c4825
authored
Jan 30, 2017
by
Alexander Alekhin
Committed by
GitHub
Jan 30, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8089 from hrnr:estimate_convert_fix
fix wrong conversion in estimateAffine2D* functions
parents
11470077
4ee25c7e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
10 deletions
+65
-10
ptsetreg.cpp
modules/calib3d/src/ptsetreg.cpp
+10
-10
test_affine2d_estimator.cpp
modules/calib3d/test/test_affine2d_estimator.cpp
+28
-0
test_affine_partial2d_estimator.cpp
modules/calib3d/test/test_affine_partial2d_estimator.cpp
+27
-0
No files found.
modules/calib3d/src/ptsetreg.cpp
View file @
124c4825
...
...
@@ -802,11 +802,11 @@ Mat estimateAffine2D(InputArray _from, InputArray _to, OutputArray _inliers,
if
(
from
.
type
()
!=
CV_32FC2
||
to
.
type
()
!=
CV_32FC2
)
{
Mat
tmp
;
from
.
convertTo
(
tmp
,
CV_32FC2
);
from
=
tmp
;
to
.
convertTo
(
tmp
,
CV_32FC2
);
to
=
tmp
;
Mat
tmp
1
,
tmp2
;
from
.
convertTo
(
tmp
1
,
CV_32FC2
);
from
=
tmp
1
;
to
.
convertTo
(
tmp
2
,
CV_32FC2
);
to
=
tmp
2
;
}
// convert to N x 1 vectors
from
=
from
.
reshape
(
2
,
count
);
...
...
@@ -869,11 +869,11 @@ Mat estimateAffinePartial2D(InputArray _from, InputArray _to, OutputArray _inlie
if
(
from
.
type
()
!=
CV_32FC2
||
to
.
type
()
!=
CV_32FC2
)
{
Mat
tmp
;
from
.
convertTo
(
tmp
,
CV_32FC2
);
from
=
tmp
;
to
.
convertTo
(
tmp
,
CV_32FC2
);
to
=
tmp
;
Mat
tmp
1
,
tmp2
;
from
.
convertTo
(
tmp
1
,
CV_32FC2
);
from
=
tmp
1
;
to
.
convertTo
(
tmp
2
,
CV_32FC2
);
to
=
tmp
2
;
}
// convert to N x 1 vectors
from
=
from
.
reshape
(
2
,
count
);
...
...
modules/calib3d/test/test_affine2d_estimator.cpp
View file @
124c4825
...
...
@@ -127,4 +127,32 @@ TEST_P(EstimateAffine2D, testNPoints)
}
}
// test conversion from other datatypes than float
TEST_P
(
EstimateAffine2D
,
testConversion
)
{
Mat
aff
(
2
,
3
,
CV_32S
);
cv
::
randu
(
aff
,
1.
,
3.
);
std
::
vector
<
Point
>
fpts
(
3
);
std
::
vector
<
Point
>
tpts
(
3
);
// setting points that are not in the same line
fpts
[
0
]
=
Point2f
(
rngIn
(
1
,
2
),
rngIn
(
5
,
6
)
);
fpts
[
1
]
=
Point2f
(
rngIn
(
3
,
4
),
rngIn
(
3
,
4
)
);
fpts
[
2
]
=
Point2f
(
rngIn
(
1
,
2
),
rngIn
(
3
,
4
)
);
transform
(
fpts
,
tpts
,
aff
);
vector
<
uchar
>
inliers
;
Mat
aff_est
=
estimateAffine2D
(
fpts
,
tpts
,
inliers
,
GetParam
()
/* method */
);
ASSERT_FALSE
(
aff_est
.
empty
());
aff
.
convertTo
(
aff
,
CV_64F
);
// need to convert before compare
EXPECT_NEAR
(
0.
,
cvtest
::
norm
(
aff_est
,
aff
,
NORM_INF
),
1e-3
);
// all must be inliers
EXPECT_EQ
(
countNonZero
(
inliers
),
3
);
}
INSTANTIATE_TEST_CASE_P
(
Calib3d
,
EstimateAffine2D
,
Method
::
all
());
modules/calib3d/test/test_affine_partial2d_estimator.cpp
View file @
124c4825
...
...
@@ -137,4 +137,31 @@ TEST_P(EstimateAffinePartial2D, testNPoints)
}
}
// test conversion from other datatypes than float
TEST_P
(
EstimateAffinePartial2D
,
testConversion
)
{
Mat
aff
=
rngPartialAffMat
();
aff
.
convertTo
(
aff
,
CV_32S
);
// convert to int to transform ints properly
std
::
vector
<
Point
>
fpts
(
3
);
std
::
vector
<
Point
>
tpts
(
3
);
fpts
[
0
]
=
Point2f
(
rngIn
(
1
,
2
),
rngIn
(
5
,
6
)
);
fpts
[
1
]
=
Point2f
(
rngIn
(
3
,
4
),
rngIn
(
3
,
4
)
);
fpts
[
2
]
=
Point2f
(
rngIn
(
1
,
2
),
rngIn
(
3
,
4
)
);
transform
(
fpts
,
tpts
,
aff
);
vector
<
uchar
>
inliers
;
Mat
aff_est
=
estimateAffinePartial2D
(
fpts
,
tpts
,
inliers
,
GetParam
()
/* method */
);
ASSERT_FALSE
(
aff_est
.
empty
());
aff
.
convertTo
(
aff
,
CV_64F
);
// need to convert back before compare
EXPECT_NEAR
(
0.
,
cvtest
::
norm
(
aff_est
,
aff
,
NORM_INF
),
1e-3
);
// all must be inliers
EXPECT_EQ
(
countNonZero
(
inliers
),
3
);
}
INSTANTIATE_TEST_CASE_P
(
Calib3d
,
EstimateAffinePartial2D
,
Method
::
all
());
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