Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
442f6b41
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,发现更多精彩内容 >>
提交
442f6b41
编写于
7月 11, 2011
作者:
A
Ana Huaman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added cornerSubPix_Demo.cpp tutorial sample code
上级
6c9f4d64
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
105 addition
and
0 deletion
+105
-0
samples/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp
...es/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp
+105
-0
未找到文件。
samples/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp
0 → 100644
浏览文件 @
442f6b41
/**
* @function cornerSubPix_Demo.cpp
* @brief Demo code for refining corner locations
* @author OpenCV team
*/
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using
namespace
cv
;
using
namespace
std
;
/// Global variables
Mat
src
,
src_gray
;
int
maxCorners
=
10
;
int
maxTrackbar
=
25
;
RNG
rng
(
12345
);
char
*
source_window
=
"Image"
;
/// Function header
void
goodFeaturesToTrack_Demo
(
int
,
void
*
);
/**
* @function main
*/
int
main
(
int
argc
,
char
**
argv
)
{
/// Load source image and convert it to gray
src
=
imread
(
argv
[
1
],
1
);
cvtColor
(
src
,
src_gray
,
CV_BGR2GRAY
);
/// Create Window
namedWindow
(
source_window
,
CV_WINDOW_AUTOSIZE
);
/// Create Trackbar to set the number of corners
createTrackbar
(
"Max corners:"
,
source_window
,
&
maxCorners
,
maxTrackbar
,
goodFeaturesToTrack_Demo
);
imshow
(
source_window
,
src
);
goodFeaturesToTrack_Demo
(
0
,
0
);
waitKey
(
0
);
return
(
0
);
}
/**
* @function goodFeaturesToTrack_Demo.cpp
* @brief Apply Shi-Tomasi corner detector
*/
void
goodFeaturesToTrack_Demo
(
int
,
void
*
)
{
if
(
maxCorners
<
1
)
{
maxCorners
=
1
;
}
/// Parameters for Shi-Tomasi algorithm
vector
<
Point2f
>
corners
;
double
qualityLevel
=
0.01
;
double
minDistance
=
10
;
int
blockSize
=
3
;
bool
useHarrisDetector
=
false
;
double
k
=
0.04
;
/// Copy the source image
Mat
copy
;
copy
=
src
.
clone
();
/// Apply corner detection
goodFeaturesToTrack
(
src_gray
,
corners
,
maxCorners
,
qualityLevel
,
minDistance
,
Mat
(),
blockSize
,
useHarrisDetector
,
k
);
/// Draw corners detected
cout
<<
"** Number of corners detected: "
<<
corners
.
size
()
<<
endl
;
int
r
=
4
;
for
(
int
i
=
0
;
i
<
corners
.
size
();
i
++
)
{
circle
(
copy
,
corners
[
i
],
r
,
Scalar
(
rng
.
uniform
(
0
,
255
),
rng
.
uniform
(
0
,
255
),
rng
.
uniform
(
0
,
255
)),
-
1
,
8
,
0
);
}
/// Show what you got
namedWindow
(
source_window
,
CV_WINDOW_AUTOSIZE
);
imshow
(
source_window
,
copy
);
/// Set the neeed parameters to find the refined corners
Size
winSize
=
Size
(
5
,
5
);
Size
zeroZone
=
Size
(
-
1
,
-
1
);
TermCriteria
criteria
=
TermCriteria
(
CV_TERMCRIT_EPS
+
CV_TERMCRIT_ITER
,
40
,
0.001
);
/// Calculate the refined corner locations
cornerSubPix
(
src_gray
,
corners
,
winSize
,
zeroZone
,
criteria
);
/// Write them down
for
(
int
i
=
0
;
i
<
corners
.
size
();
i
++
)
{
cout
<<
" -- Refined Corner ["
<<
i
<<
"] ("
<<
corners
[
i
].
x
<<
","
<<
corners
[
i
].
y
<<
")"
<<
endl
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录