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
e3690db4
Commit
e3690db4
authored
Jan 12, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5949 from akarsakov:fixed_solvePnPRansac_input_handling
parents
5a998335
e784ea71
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
13 deletions
+52
-13
calib3d.hpp
modules/calib3d/include/opencv2/calib3d.hpp
+4
-4
ptsetreg.cpp
modules/calib3d/src/ptsetreg.cpp
+1
-1
solvepnp.cpp
modules/calib3d/src/solvepnp.cpp
+2
-0
test_solvepnp_ransac.cpp
modules/calib3d/test/test_solvepnp_ransac.cpp
+45
-8
No files found.
modules/calib3d/include/opencv2/calib3d.hpp
View file @
e3690db4
...
...
@@ -515,9 +515,9 @@ CV_EXPORTS_W void projectPoints( InputArray objectPoints,
/** @brief Finds an object pose from 3D-2D point correspondences.
@param objectPoints Array of object points in the object coordinate space,
3xN/
Nx3 1-channel or
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
1xN/Nx1 3-channel, where N is the number of points. vector\<Point3f\> can be also passed here.
@param imagePoints Array of corresponding image points,
2xN/
Nx2 1-channel or 1xN/Nx1 2-channel,
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
where N is the number of points. vector\<Point2f\> can be also passed here.
@param cameraMatrix Input camera matrix \f$A = \vecthreethree{fx}{0}{cx}{0}{fy}{cy}{0}{0}{1}\f$ .
@param distCoeffs Input vector of distortion coefficients
...
...
@@ -572,9 +572,9 @@ CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
/** @brief Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
@param objectPoints Array of object points in the object coordinate space,
3xN/
Nx3 1-channel or
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
1xN/Nx1 3-channel, where N is the number of points. vector\<Point3f\> can be also passed here.
@param imagePoints Array of corresponding image points,
2xN/
Nx2 1-channel or 1xN/Nx1 2-channel,
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
where N is the number of points. vector\<Point2f\> can be also passed here.
@param cameraMatrix Input camera matrix \f$A = \vecthreethree{fx}{0}{cx}{0}{fy}{cy}{0}{0}{1}\f$ .
@param distCoeffs Input vector of distortion coefficients
...
...
modules/calib3d/src/ptsetreg.cpp
View file @
e3690db4
...
...
@@ -109,9 +109,9 @@ public:
cv
::
AutoBuffer
<
int
>
_idx
(
modelPoints
);
int
*
idx
=
_idx
;
int
i
=
0
,
j
,
k
,
iters
=
0
;
int
esz1
=
(
int
)
m1
.
elemSize
(),
esz2
=
(
int
)
m2
.
elemSize
();
int
d1
=
m1
.
channels
()
>
1
?
m1
.
channels
()
:
m1
.
cols
;
int
d2
=
m2
.
channels
()
>
1
?
m2
.
channels
()
:
m2
.
cols
;
int
esz1
=
(
int
)
m1
.
elemSize1
()
*
d1
,
esz2
=
(
int
)
m2
.
elemSize1
()
*
d2
;
int
count
=
m1
.
checkVector
(
d1
),
count2
=
m2
.
checkVector
(
d2
);
const
int
*
m1ptr
=
m1
.
ptr
<
int
>
(),
*
m2ptr
=
m2
.
ptr
<
int
>
();
...
...
modules/calib3d/src/solvepnp.cpp
View file @
e3690db4
...
...
@@ -270,6 +270,8 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
{
vector
<
Point3d
>
opoints_inliers
;
vector
<
Point2d
>
ipoints_inliers
;
opoints
=
opoints
.
reshape
(
3
);
ipoints
=
ipoints
.
reshape
(
2
);
opoints
.
convertTo
(
opoints_inliers
,
CV_64F
);
ipoints
.
convertTo
(
ipoints_inliers
,
CV_64F
);
...
...
modules/calib3d/test/test_solvepnp_ransac.cpp
View file @
e3690db4
...
...
@@ -314,6 +314,43 @@ TEST(Calib3d_SolvePnPRansac, concurrency)
EXPECT_LT
(
tnorm
,
1e-6
);
}
TEST
(
Calib3d_SolvePnPRansac
,
input_type
)
{
const
int
numPoints
=
10
;
Matx33d
intrinsics
(
5.4794130238156129e+002
,
0.
,
2.9835545700043139e+002
,
0.
,
5.4817724002728005e+002
,
2.3062194051986233e+002
,
0.
,
0.
,
1.
);
std
::
vector
<
cv
::
Point3f
>
points3d
;
std
::
vector
<
cv
::
Point2f
>
points2d
;
for
(
int
i
=
0
;
i
<
numPoints
;
i
++
)
{
points3d
.
push_back
(
cv
::
Point3i
(
i
,
0
,
0
));
points2d
.
push_back
(
cv
::
Point2i
(
i
,
0
));
}
Mat
R1
,
t1
,
R2
,
t2
,
R3
,
t3
,
R4
,
t4
;
EXPECT_TRUE
(
solvePnPRansac
(
points3d
,
points2d
,
intrinsics
,
cv
::
Mat
(),
R1
,
t1
));
Mat
points3dMat
(
points3d
);
Mat
points2dMat
(
points2d
);
EXPECT_TRUE
(
solvePnPRansac
(
points3dMat
,
points2dMat
,
intrinsics
,
cv
::
Mat
(),
R2
,
t2
));
points3dMat
=
points3dMat
.
reshape
(
3
,
1
);
points2dMat
=
points2dMat
.
reshape
(
2
,
1
);
EXPECT_TRUE
(
solvePnPRansac
(
points3dMat
,
points2dMat
,
intrinsics
,
cv
::
Mat
(),
R3
,
t3
));
points3dMat
=
points3dMat
.
reshape
(
1
,
numPoints
);
points2dMat
=
points2dMat
.
reshape
(
1
,
numPoints
);
EXPECT_TRUE
(
solvePnPRansac
(
points3dMat
,
points2dMat
,
intrinsics
,
cv
::
Mat
(),
R4
,
t4
));
EXPECT_LE
(
norm
(
R1
,
R2
,
NORM_INF
),
1e-6
);
EXPECT_LE
(
norm
(
t1
,
t2
,
NORM_INF
),
1e-6
);
EXPECT_LE
(
norm
(
R1
,
R3
,
NORM_INF
),
1e-6
);
EXPECT_LE
(
norm
(
t1
,
t3
,
NORM_INF
),
1e-6
);
EXPECT_LE
(
norm
(
R1
,
R4
,
NORM_INF
),
1e-6
);
EXPECT_LE
(
norm
(
t1
,
t4
,
NORM_INF
),
1e-6
);
}
TEST
(
Calib3d_SolvePnP
,
double_support
)
{
Matx33d
intrinsics
(
5.4794130238156129e+002
,
0.
,
2.9835545700043139e+002
,
0.
,
...
...
@@ -335,8 +372,8 @@ TEST(Calib3d_SolvePnP, double_support)
solvePnPRansac
(
points3dF
,
points2dF
,
intrinsics
,
cv
::
Mat
(),
RF
,
tF
,
true
,
100
,
8.
f
,
0.999
,
inliers
,
cv
::
SOLVEPNP_P3P
);
solvePnPRansac
(
points3d
,
points2d
,
intrinsics
,
cv
::
Mat
(),
R
,
t
,
true
,
100
,
8.
f
,
0.999
,
inliers
,
cv
::
SOLVEPNP_P3P
);
ASSER
T_LE
(
norm
(
R
,
Mat_
<
double
>
(
RF
),
NORM_INF
),
1e-3
);
ASSER
T_LE
(
norm
(
t
,
Mat_
<
double
>
(
tF
),
NORM_INF
),
1e-3
);
EXPEC
T_LE
(
norm
(
R
,
Mat_
<
double
>
(
RF
),
NORM_INF
),
1e-3
);
EXPEC
T_LE
(
norm
(
t
,
Mat_
<
double
>
(
tF
),
NORM_INF
),
1e-3
);
}
TEST
(
Calib3d_SolvePnP
,
translation
)
...
...
@@ -365,16 +402,16 @@ TEST(Calib3d_SolvePnP, translation)
tvec
=
(
Mat_
<
float
>
(
3
,
1
)
<<
100
,
100
,
0
);
solvePnP
(
p3d
,
p2d
,
cameraIntrinsic
,
noArray
(),
rvec
,
tvec
,
true
);
ASSER
T_TRUE
(
checkRange
(
rvec
));
ASSER
T_TRUE
(
checkRange
(
tvec
));
EXPEC
T_TRUE
(
checkRange
(
rvec
));
EXPEC
T_TRUE
(
checkRange
(
tvec
));
rvec
=
(
Mat_
<
double
>
(
3
,
1
)
<<
0
,
0
,
0
);
tvec
=
(
Mat_
<
double
>
(
3
,
1
)
<<
100
,
100
,
0
);
solvePnP
(
p3d
,
p2d
,
cameraIntrinsic
,
noArray
(),
rvec
,
tvec
,
true
);
ASSER
T_TRUE
(
checkRange
(
rvec
));
ASSER
T_TRUE
(
checkRange
(
tvec
));
EXPEC
T_TRUE
(
checkRange
(
rvec
));
EXPEC
T_TRUE
(
checkRange
(
tvec
));
solvePnP
(
p3d
,
p2d
,
cameraIntrinsic
,
noArray
(),
rvec
,
tvec
,
false
);
ASSER
T_TRUE
(
checkRange
(
rvec
));
ASSER
T_TRUE
(
checkRange
(
tvec
));
EXPEC
T_TRUE
(
checkRange
(
rvec
));
EXPEC
T_TRUE
(
checkRange
(
tvec
));
}
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