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
747c6a2b
Commit
747c6a2b
authored
Jul 08, 2014
by
edgarriba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solvepnpransac() interface changed
parent
dd52d1b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
24 deletions
+14
-24
solvepnp.cpp
modules/calib3d/src/solvepnp.cpp
+14
-24
No files found.
modules/calib3d/src/solvepnp.cpp
View file @
747c6a2b
...
@@ -341,7 +341,7 @@ public:
...
@@ -341,7 +341,7 @@ public:
void
cv
::
solvePnPRansac
(
InputArray
_opoints
,
InputArray
_ipoints
,
void
cv
::
solvePnPRansac
(
InputArray
_opoints
,
InputArray
_ipoints
,
InputArray
_cameraMatrix
,
InputArray
_distCoeffs
,
InputArray
_cameraMatrix
,
InputArray
_distCoeffs
,
OutputArray
_rvec
,
OutputArray
_tvec
,
bool
useExtrinsicGuess
,
OutputArray
_rvec
,
OutputArray
_tvec
,
bool
useExtrinsicGuess
,
int
iterationsCount
,
float
reprojectionError
,
int
minInliersCount
,
int
iterationsCount
,
float
reprojectionError
,
float
confidence
,
OutputArray
_inliers
,
int
flags
)
OutputArray
_inliers
,
int
flags
)
{
{
...
@@ -349,24 +349,14 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
...
@@ -349,24 +349,14 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
Mat
cameraMatrix
=
_cameraMatrix
.
getMat
(),
distCoeffs
=
_distCoeffs
.
getMat
();
Mat
cameraMatrix
=
_cameraMatrix
.
getMat
(),
distCoeffs
=
_distCoeffs
.
getMat
();
CV_Assert
(
opoints
.
isContinuous
());
CV_Assert
(
opoints
.
isContinuous
());
CV_Assert
(
opoints
.
depth
()
==
CV_32F
);
CV_Assert
(
opoints
.
depth
()
==
CV_32F
||
opoints
.
depth
()
==
CV_64F
);
CV_Assert
((
opoints
.
rows
==
1
&&
opoints
.
channels
()
==
3
)
||
opoints
.
cols
*
opoints
.
channels
()
==
3
);
CV_Assert
((
opoints
.
rows
==
1
&&
opoints
.
channels
()
==
3
)
||
opoints
.
cols
*
opoints
.
channels
()
==
3
);
CV_Assert
(
ipoints
.
isContinuous
());
CV_Assert
(
ipoints
.
isContinuous
());
CV_Assert
(
ipoints
.
depth
()
==
CV_32F
);
CV_Assert
(
ipoints
.
depth
()
==
CV_32F
||
ipoints
.
depth
()
==
CV_64F
);
CV_Assert
((
ipoints
.
rows
==
1
&&
ipoints
.
channels
()
==
2
)
||
ipoints
.
cols
*
ipoints
.
channels
()
==
2
);
CV_Assert
((
ipoints
.
rows
==
1
&&
ipoints
.
channels
()
==
2
)
||
ipoints
.
cols
*
ipoints
.
channels
()
==
2
);
Mat
objectPoints
=
opoints
.
reshape
(
3
,
1
),
imagePoints
=
ipoints
.
reshape
(
2
,
1
);
Mat
objectPoints
=
opoints
.
reshape
(
3
,
1
),
imagePoints
=
ipoints
.
reshape
(
2
,
1
);
if
(
minInliersCount
<=
0
)
minInliersCount
=
objectPoints
.
cols
;
cv
::
pnpransac
::
Parameters
params
;
params
.
iterationsCount
=
iterationsCount
;
// maxIters
params
.
minInliersCount
=
minInliersCount
;
params
.
reprojectionError
=
reprojectionError
;
// threshold
params
.
useExtrinsicGuess
=
useExtrinsicGuess
;
params
.
camera
.
init
(
cameraMatrix
,
distCoeffs
);
params
.
flags
=
flags
;
Ptr
<
PointSetRegistrator
::
Callback
>
cb
;
// pointer to callback
Ptr
<
PointSetRegistrator
::
Callback
>
cb
;
// pointer to callback
_rvec
.
create
(
3
,
1
,
CV_64FC1
);
_rvec
.
create
(
3
,
1
,
CV_64FC1
);
...
@@ -379,34 +369,34 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
...
@@ -379,34 +369,34 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
rvec
=
_rvec
.
getMat
();
rvec
=
_rvec
.
getMat
();
tvec
=
_tvec
.
getMat
();
tvec
=
_tvec
.
getMat
();
cb
=
makePtr
<
PnPRansacCallback
>
(
params
.
camera
.
intrinsics
,
params
.
camera
.
distortion
,
cb
=
makePtr
<
PnPRansacCallback
>
(
cameraMatrix
,
distCoeffs
,
flags
,
params
.
flags
,
params
.
useExtrinsicGuess
,
rvec
,
tvec
);
useExtrinsicGuess
,
rvec
,
tvec
);
}
}
else
else
{
{
rvec
=
Mat
(
3
,
1
,
CV_64FC1
);
rvec
=
Mat
(
3
,
1
,
CV_64FC1
);
tvec
=
Mat
(
3
,
1
,
CV_64FC1
);
tvec
=
Mat
(
3
,
1
,
CV_64FC1
);
cb
=
makePtr
<
PnPRansacCallback
>
(
params
.
camera
.
intrinsics
,
params
.
camera
.
distortion
,
cb
=
makePtr
<
PnPRansacCallback
>
(
cameraMatrix
,
distCoeffs
,
flags
,
params
.
flags
,
params
.
useExtrinsicGuess
,
rvec
,
tvec
);
useExtrinsicGuess
,
rvec
,
tvec
);
}
}
int
model_points
=
7
;
//
number of model points
int
model_points
=
3
;
// minimum of
number of model points
double
param1
=
params
.
reprojectionError
;
// reprojection error
double
param1
=
reprojectionError
;
// reprojection error
double
param2
=
0.99
;
// confidence
double
param2
=
confidence
;
// confidence
int
param3
=
params
.
iterationsCount
;
// number maximum iterations
int
param3
=
iterationsCount
;
// number maximum iterations
cv
::
Mat
_local_model
(
3
,
2
,
CV_64FC1
);
cv
::
Mat
_local_model
(
3
,
2
,
CV_64FC1
);
cv
::
Mat
_mask_local_inliers
(
1
,
opoints
.
rows
,
CV_8UC1
);
cv
::
Mat
_mask_local_inliers
(
1
,
opoints
.
rows
,
CV_8UC1
);
// call Ransac
// call Ransac
int
result
=
createRANSACPointSetRegistrator
(
cb
,
model_points
,
param1
,
param2
,
param3
)
->
run
(
_opoints
,
_ipoints
,
_local_model
,
_mask_local_inliers
);
int
result
=
createRANSACPointSetRegistrator
(
cb
,
model_points
,
param1
,
param2
,
param3
)
->
run
(
_opoints
,
_ipoints
,
_local_model
,
_mask_local_inliers
);
_rvec
.
assign
(
_local_model
.
rowRange
(
0
,
3
));
// output rotation vector
_rvec
.
assign
(
_local_model
.
rowRange
(
0
,
3
));
// output rotation vector
_tvec
.
assign
(
_local_model
.
rowRange
(
3
,
6
));
// output translation vector
_tvec
.
assign
(
_local_model
.
rowRange
(
3
,
6
));
// output translation vector
//std::cout << _mask_local_inliers.type() << std::endl;
Mat
_local_inliers
;
Mat
_local_inliers
;
int
count
=
0
;
int
count
=
0
;
for
(
int
i
=
0
;
i
<
_mask_local_inliers
.
rows
;
++
i
)
for
(
int
i
=
0
;
i
<
_mask_local_inliers
.
rows
;
++
i
)
...
...
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