Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
2b660bf5
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,发现更多精彩内容 >>
提交
2b660bf5
编写于
11月 29, 2010
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added flag to treat input file as a videofile (patch by Ethan Rublee; ticket #392)
上级
bad4ca2a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
37 deletion
+42
-37
samples/cpp/calibration.cpp
samples/cpp/calibration.cpp
+42
-37
未找到文件。
samples/cpp/calibration.cpp
浏览文件 @
2b660bf5
...
...
@@ -60,6 +60,8 @@ void help()
" [-a <aspectRatio>] # fix aspect ratio (fx/fy)
\n
"
" [-p] # fix the principal point at the center
\n
"
" [-v] # flip the captured images around the horizontal axis
\n
"
" [-V] # use a video file, and not an image list, uses
\n
"
" # [input_data] string for the video file name
\n
"
" [-su] # show undistorted images after calibration
\n
"
" [input_data] # input data, one of the following:
\n
"
" # - text file with a list of the images of the board
\n
"
...
...
@@ -126,10 +128,11 @@ static bool runCalibration( vector<vector<Point2f> > imagePoints,
vector
<
vector
<
Point3f
>
>
objectPoints
(
1
);
calcChessboardCorners
(
boardSize
,
squareSize
,
objectPoints
[
0
]);
objectPoints
.
resize
(
imagePoints
.
size
(),
objectPoints
[
0
]);
objectPoints
.
resize
(
imagePoints
.
size
(),
objectPoints
[
0
]);
calibrateCamera
(
objectPoints
,
imagePoints
,
imageSize
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
,
flags
|
CV_CALIB_FIX_K4
|
CV_CALIB_FIX_K5
);
///*|CV_CALIB_FIX_K3*/|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);
distCoeffs
,
rvecs
,
tvecs
,
flags
|
CV_CALIB_FIX_K4
|
CV_CALIB_FIX_K5
);
///*|CV_CALIB_FIX_K3*/|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);
bool
ok
=
checkRange
(
cameraMatrix
)
&&
checkRange
(
distCoeffs
);
...
...
@@ -277,6 +280,7 @@ int main( int argc, char** argv )
VideoCapture
capture
;
bool
flipVertical
=
false
;
bool
showUndistorted
=
false
;
bool
videofile
=
false
;
int
delay
=
1000
;
clock_t
prevTimestamp
=
0
;
int
mode
=
DETECTION
;
...
...
@@ -284,11 +288,10 @@ int main( int argc, char** argv )
vector
<
vector
<
Point2f
>
>
imagePoints
;
vector
<
string
>
imageList
;
if
(
argc
<
2
)
{
help
();
return
0
;
help
();
return
0
;
}
for
(
i
=
1
;
i
<
argc
;
i
++
)
...
...
@@ -327,11 +330,11 @@ int main( int argc, char** argv )
}
else
if
(
strcmp
(
s
,
"-op"
)
==
0
)
{
writePoints
=
1
;
writePoints
=
true
;
}
else
if
(
strcmp
(
s
,
"-oe"
)
==
0
)
{
writeExtrinsics
=
1
;
writeExtrinsics
=
true
;
}
else
if
(
strcmp
(
s
,
"-zt"
)
==
0
)
{
...
...
@@ -343,7 +346,11 @@ int main( int argc, char** argv )
}
else
if
(
strcmp
(
s
,
"-v"
)
==
0
)
{
flipVertical
=
1
;
flipVertical
=
true
;
}
else
if
(
strcmp
(
s
,
"-V"
)
==
0
)
{
videofile
=
true
;
}
else
if
(
strcmp
(
s
,
"-o"
)
==
0
)
{
...
...
@@ -355,18 +362,18 @@ int main( int argc, char** argv )
}
else
if
(
s
[
0
]
!=
'-'
)
{
if
(
isdigit
(
s
[
0
])
)
sscanf
(
s
,
"%d"
,
&
cameraId
);
else
inputFilename
=
s
;
}
if
(
isdigit
(
s
[
0
])
)
sscanf
(
s
,
"%d"
,
&
cameraId
);
else
inputFilename
=
s
;
}
else
return
fprintf
(
stderr
,
"Unknown option %s"
,
s
),
-
1
;
}
if
(
inputFilename
)
{
if
(
readStringList
(
inputFilename
,
imageList
)
)
if
(
!
videofile
&&
readStringList
(
inputFilename
,
imageList
)
)
mode
=
CAPTURING
;
else
capture
.
open
(
inputFilename
);
...
...
@@ -415,27 +422,25 @@ int main( int argc, char** argv )
flip
(
view
,
view
,
0
);
vector
<
Point2f
>
pointbuf
;
cvtColor
(
view
,
viewGray
,
CV_BGR2GRAY
);
bool
found
=
findChessboardCorners
(
view
,
boardSize
,
pointbuf
,
CV_CALIB_CB_ADAPTIVE_THRESH
&
CV_CALIB_CB_FAST_CHECK
&
CV_CALIB_CB_NORMALIZE_IMAGE
);
// improve the found corners' coordinate accuracy
if
(
found
)
cornerSubPix
(
viewGray
,
pointbuf
,
Size
(
11
,
11
),
Size
(
-
1
,
-
1
),
TermCriteria
(
CV_TERMCRIT_EPS
+
CV_TERMCRIT_ITER
,
30
,
0.1
));
if
(
mode
==
CAPTURING
&&
found
&&
(
!
capture
.
isOpened
()
||
clock
()
-
prevTimestamp
>
delay
*
1e-3
*
CLOCKS_PER_SEC
)
)
{
imagePoints
.
push_back
(
pointbuf
);
prevTimestamp
=
clock
();
blink
=
capture
.
isOpened
();
}
if
(
found
)
drawChessboardCorners
(
view
,
boardSize
,
Mat
(
pointbuf
),
found
);
bool
found
=
findChessboardCorners
(
view
,
boardSize
,
pointbuf
,
CV_CALIB_CB_ADAPTIVE_THRESH
&
CV_CALIB_CB_FAST_CHECK
&
CV_CALIB_CB_NORMALIZE_IMAGE
);
// improve the found corners' coordinate accuracy
if
(
found
)
cornerSubPix
(
viewGray
,
pointbuf
,
Size
(
11
,
11
),
Size
(
-
1
,
-
1
),
TermCriteria
(
CV_TERMCRIT_EPS
+
CV_TERMCRIT_ITER
,
30
,
0.1
));
if
(
mode
==
CAPTURING
&&
found
&&
(
!
capture
.
isOpened
()
||
clock
()
-
prevTimestamp
>
delay
*
1e-3
*
CLOCKS_PER_SEC
)
)
{
imagePoints
.
push_back
(
pointbuf
);
prevTimestamp
=
clock
();
blink
=
capture
.
isOpened
();
}
if
(
found
)
drawChessboardCorners
(
view
,
boardSize
,
Mat
(
pointbuf
),
found
);
string
msg
=
mode
==
CAPTURING
?
"100/100"
:
mode
==
CALIBRATED
?
"Calibrated"
:
"Press 'g' to start"
;
...
...
@@ -445,11 +450,11 @@ int main( int argc, char** argv )
if
(
mode
==
CAPTURING
)
{
if
(
undistortImage
)
msg
=
format
(
"%d/%d Undist"
,
(
int
)
imagePoints
.
size
(),
nframes
);
if
(
undistortImage
)
msg
=
format
(
"%d/%d Undist"
,
(
int
)
imagePoints
.
size
(),
nframes
);
else
msg
=
format
(
"%d/%d"
,
(
int
)
imagePoints
.
size
(),
nframes
);
}
msg
=
format
(
"%d/%d"
,
(
int
)
imagePoints
.
size
(),
nframes
);
}
putText
(
view
,
msg
,
textOrigin
,
1
,
1
,
mode
!=
CALIBRATED
?
Scalar
(
0
,
0
,
255
)
:
Scalar
(
0
,
255
,
0
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录