Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
ba5a8ee2
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ba5a8ee2
编写于
7月 09, 2014
作者:
E
edgarriba
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Solvepnpransac() returns boolean
上级
ce07024a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
44 deletion
+29
-44
modules/calib3d/include/opencv2/calib3d.hpp
modules/calib3d/include/opencv2/calib3d.hpp
+1
-1
modules/calib3d/src/solvepnp.cpp
modules/calib3d/src/solvepnp.cpp
+28
-43
未找到文件。
modules/calib3d/include/opencv2/calib3d.hpp
浏览文件 @
ba5a8ee2
...
...
@@ -154,7 +154,7 @@ CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
bool
useExtrinsicGuess
=
false
,
int
flags
=
ITERATIVE
);
//! computes the camera pose from a few 3D points and the corresponding projections. The outliers are possible.
CV_EXPORTS_W
void
solvePnPRansac
(
InputArray
objectPoints
,
InputArray
imagePoints
,
CV_EXPORTS_W
bool
solvePnPRansac
(
InputArray
objectPoints
,
InputArray
imagePoints
,
InputArray
cameraMatrix
,
InputArray
distCoeffs
,
OutputArray
rvec
,
OutputArray
tvec
,
bool
useExtrinsicGuess
=
false
,
int
iterationsCount
=
100
,
...
...
modules/calib3d/src/solvepnp.cpp
浏览文件 @
ba5a8ee2
...
...
@@ -98,7 +98,7 @@ bool cv::solvePnP( InputArray _opoints, InputArray _ipoints,
return
false
;
}
namespace
cv
/*
namespace cv
{
namespace pnpransac
{
...
...
@@ -271,7 +271,7 @@ namespace cv
RNG PnPSolver::generator;
}
}
}
*/
class
PnPRansacCallback
:
public
PointSetRegistrator
::
Callback
{
...
...
@@ -283,7 +283,7 @@ public:
rvec
(
_rvec
),
tvec
(
_tvec
)
{}
/* Pre: True */
/* Post: compute _model with given points an eturn number of found models */
/* Post: compute _model with given points an
r
eturn number of found models */
int
runKernel
(
InputArray
_m1
,
InputArray
_m2
,
OutputArray
_model
)
const
{
Mat
opoints
=
_m1
.
getMat
(),
ipoints
=
_m2
.
getMat
();
...
...
@@ -291,15 +291,9 @@ public:
bool
correspondence
=
cv
::
solvePnP
(
_m1
,
_m2
,
cameraMatrix
,
distCoeffs
,
rvec
,
tvec
,
useExtrinsicGuess
,
flags
);
if
(
correspondence
)
{
Mat
_local_model
;
_local_model
.
push_back
(
rvec
);
_local_model
.
push_back
(
tvec
);
_local_model
.
copyTo
(
_model
);
}
Mat
_local_model
;
cv
::
hconcat
(
rvec
,
tvec
,
_local_model
);
_local_model
.
copyTo
(
_model
);
return
correspondence
;
}
...
...
@@ -312,8 +306,8 @@ public:
Mat
opoints
=
_m1
.
getMat
(),
ipoints
=
_m2
.
getMat
(),
model
=
_model
.
getMat
();
int
i
,
count
=
opoints
.
cols
;
Mat
_rvec
=
model
.
rowRange
(
0
,
3
);
Mat
_tvec
=
model
.
rowRange
(
3
,
6
);
Mat
_rvec
=
model
.
col
(
0
);
Mat
_tvec
=
model
.
col
(
1
);
Mat
projpoints
(
count
,
2
,
CV_32FC1
);
cv
::
projectPoints
(
opoints
,
_rvec
,
_tvec
,
cameraMatrix
,
distCoeffs
,
projpoints
);
...
...
@@ -338,7 +332,7 @@ public:
Mat
tvec
;
};
void
cv
::
solvePnPRansac
(
InputArray
_opoints
,
InputArray
_ipoints
,
bool
cv
::
solvePnPRansac
(
InputArray
_opoints
,
InputArray
_ipoints
,
InputArray
_cameraMatrix
,
InputArray
_distCoeffs
,
OutputArray
_rvec
,
OutputArray
_tvec
,
bool
useExtrinsicGuess
,
int
iterationsCount
,
float
reprojectionError
,
float
confidence
,
...
...
@@ -355,34 +349,16 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
CV_Assert
(
ipoints
.
depth
()
==
CV_32F
||
ipoints
.
depth
()
==
CV_64F
);
CV_Assert
((
ipoints
.
rows
==
1
&&
ipoints
.
channels
()
==
2
)
||
ipoints
.
cols
*
ipoints
.
channels
()
==
2
);
Mat
objectPoints
=
opoints
.
reshape
(
3
,
1
),
imagePoints
=
ipoints
.
reshape
(
2
,
1
);
Ptr
<
PointSetRegistrator
::
Callback
>
cb
;
// pointer to callback
_rvec
.
create
(
3
,
1
,
CV_64FC1
);
_tvec
.
create
(
3
,
1
,
CV_64FC1
);
Mat
rvec
,
tvec
;
if
(
useExtrinsicGuess
)
// use given rvec & tvec
{
rvec
=
_rvec
.
getMat
();
tvec
=
_tvec
.
getMat
();
cb
=
makePtr
<
PnPRansacCallback
>
(
cameraMatrix
,
distCoeffs
,
flags
,
useExtrinsicGuess
,
rvec
,
tvec
);
}
else
{
rvec
=
Mat
(
3
,
1
,
CV_64FC1
);
tvec
=
Mat
(
3
,
1
,
CV_64FC1
);
Mat
rvec
=
useExtrinsicGuess
?
_rvec
.
getMat
()
:
Mat
(
3
,
1
,
CV_64FC1
);
Mat
tvec
=
useExtrinsicGuess
?
_tvec
.
getMat
()
:
Mat
(
3
,
1
,
CV_64FC1
);
cb
=
makePtr
<
PnPRansacCallback
>
(
cameraMatrix
,
distCoeffs
,
flags
,
useExtrinsicGuess
,
rvec
,
tvec
);
}
Ptr
<
PointSetRegistrator
::
Callback
>
cb
;
// pointer to callback
cb
=
makePtr
<
PnPRansacCallback
>
(
cameraMatrix
,
distCoeffs
,
flags
,
useExtrinsicGuess
,
rvec
,
tvec
);
int
model_points
=
3
;
// minimum of number of model points
int
model_points
=
6
;
// minimum of number of model points
double
param1
=
reprojectionError
;
// reprojection error
double
param2
=
confidence
;
// confidence
int
param3
=
iterationsCount
;
// number maximum iterations
...
...
@@ -391,11 +367,20 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
cv
::
Mat
_mask_local_inliers
(
1
,
opoints
.
rows
,
CV_8UC1
);
// 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
);
if
(
result
<=
0
||
_local_model
.
rows
<=
0
)
{
_rvec
.
assign
(
rvec
);
// output rotation vector
_tvec
.
assign
(
tvec
);
// output translation vector
_rvec
.
assign
(
_local_model
.
rowRange
(
0
,
3
));
// output rotation vector
_tvec
.
assign
(
_local_model
.
rowRange
(
3
,
6
));
// output translation vector
return
false
;
}
else
{
_rvec
.
assign
(
_local_model
.
col
(
0
));
// output rotation vector
_tvec
.
assign
(
_local_model
.
col
(
1
));
// output translation vector
}
Mat
_local_inliers
;
int
count
=
0
;
...
...
@@ -452,5 +437,5 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
if( _inliers.needed() )
_inliers.release();
}*/
return
;
return
true
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录