Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
42d5b1fb
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
42d5b1fb
编写于
7月 18, 2016
作者:
C
catree
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Re-add peopledetect.cpp sample.
上级
69c4e84d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
115 addition
and
0 deletion
+115
-0
samples/cpp/peopledetect.cpp
samples/cpp/peopledetect.cpp
+115
-0
未找到文件。
samples/cpp/peopledetect.cpp
0 → 100644
浏览文件 @
42d5b1fb
#include <opencv2/objdetect.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
static
void
help
()
{
cout
<<
"
\n
This program demonstrates the use of the HoG descriptor using
\n
"
" HOGDescriptor::hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
\n
"
"Usage:
\n
"
"./peopledetect --i=<image_filename> | --d=<image_directory>
\n\n
"
"During execution:
\n\t
Hit q or ESC key to quit.
\n
"
"
\t
Using OpenCV version "
<<
CV_VERSION
<<
"
\n
"
<<
endl
;
}
const
char
*
keys
=
{
"{help h||}"
"{image i| ../data/basketball2.png|input image name}"
"{directory d||images directory}"
};
static
void
detectAndDraw
(
const
HOGDescriptor
&
hog
,
Mat
&
img
)
{
vector
<
Rect
>
found
,
found_filtered
;
double
t
=
(
double
)
getTickCount
();
// Run the detector with default parameters. to get a higher hit-rate
// (and more false alarms, respectively), decrease the hitThreshold and
// groupThreshold (set groupThreshold to 0 to turn off the grouping completely).
hog
.
detectMultiScale
(
img
,
found
,
0
,
Size
(
8
,
8
),
Size
(
32
,
32
),
1.05
,
2
);
t
=
(
double
)
getTickCount
()
-
t
;
cout
<<
"detection time = "
<<
(
t
*
1000.
/
cv
::
getTickFrequency
())
<<
" ms"
<<
endl
;
for
(
size_t
i
=
0
;
i
<
found
.
size
();
i
++
)
{
Rect
r
=
found
[
i
];
size_t
j
;
// Do not add small detections inside a bigger detection.
for
(
j
=
0
;
j
<
found
.
size
();
j
++
)
if
(
j
!=
i
&&
(
r
&
found
[
j
])
==
r
)
break
;
if
(
j
==
found
.
size
()
)
found_filtered
.
push_back
(
r
);
}
for
(
size_t
i
=
0
;
i
<
found_filtered
.
size
();
i
++
)
{
Rect
r
=
found_filtered
[
i
];
// The HOG detector returns slightly larger rectangles than the real objects,
// so we slightly shrink the rectangles to get a nicer output.
r
.
x
+=
cvRound
(
r
.
width
*
0.1
);
r
.
width
=
cvRound
(
r
.
width
*
0.8
);
r
.
y
+=
cvRound
(
r
.
height
*
0.07
);
r
.
height
=
cvRound
(
r
.
height
*
0.8
);
rectangle
(
img
,
r
.
tl
(),
r
.
br
(),
cv
::
Scalar
(
0
,
255
,
0
),
3
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
CommandLineParser
parser
(
argc
,
argv
,
keys
);
if
(
parser
.
has
(
"help"
))
{
help
();
return
0
;
}
HOGDescriptor
hog
;
hog
.
setSVMDetector
(
HOGDescriptor
::
getDefaultPeopleDetector
());
namedWindow
(
"people detector"
,
1
);
string
pattern_glob
=
""
;
if
(
parser
.
has
(
"directory"
))
{
pattern_glob
=
parser
.
get
<
string
>
(
"directory"
);
}
else
if
(
parser
.
has
(
"image"
))
{
pattern_glob
=
parser
.
get
<
string
>
(
"image"
);
}
if
(
!
pattern_glob
.
empty
())
{
vector
<
String
>
filenames
;
String
folder
(
pattern_glob
);
glob
(
folder
,
filenames
);
for
(
vector
<
String
>::
const_iterator
it
=
filenames
.
begin
();
it
!=
filenames
.
end
();
++
it
)
{
cout
<<
"
\n
Read: "
<<
*
it
<<
endl
;
// Read current image
Mat
current_image
=
imread
(
*
it
);
if
(
current_image
.
empty
())
continue
;
detectAndDraw
(
hog
,
current_image
);
imshow
(
"people detector"
,
current_image
);
int
c
=
waitKey
(
0
)
&
255
;
if
(
c
==
'q'
||
c
==
'Q'
||
c
==
27
)
break
;
}
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录