Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
bd9ca48f
O
Opencv
项目概览
Greenplum
/
Opencv
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
bd9ca48f
编写于
11月 13, 2012
作者:
M
marina.kolpakova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
export to python/java
上级
665bf430
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
57 deletion
+57
-57
modules/objdetect/doc/soft_cascade.rst
modules/objdetect/doc/soft_cascade.rst
+9
-2
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+8
-5
modules/objdetect/src/softcascade.cpp
modules/objdetect/src/softcascade.cpp
+23
-0
modules/objdetect/test/test_softcascade.cpp
modules/objdetect/test/test_softcascade.cpp
+17
-50
未找到文件。
modules/objdetect/doc/soft_cascade.rst
浏览文件 @
bd9ca48f
...
...
@@ -39,6 +39,7 @@ Implementation of soft (stageless) cascaded detector. ::
cv::AlgorithmInfo* info() const;
virtual bool load(const FileNode& fn);
virtual void detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const;
virtual void detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const;
};
...
...
@@ -80,10 +81,16 @@ SCascade::detect
--------------------------
Apply cascade to an input frame and return the vector of Decection objcts.
.. ocv:function:: bool SCascade::detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const
.. ocv:function:: void SCascade::detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const
.. ocv:function:: void SCascade::detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const
:param image: a frame on which detector will be applied.
:param rois: a vector of regions of interest. Only the objects that fall into one of the regions will be returned.
:param objects: an output array of Detections.
\ No newline at end of file
:param objects: an output array of Detections.
:param rects: an output array of bounding rectangles for detected objects.
:param confs: an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th configence.
\ No newline at end of file
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
浏览文件 @
bd9ca48f
...
...
@@ -490,7 +490,7 @@ protected:
// Implementation of soft (stageless) cascaded detector.
class
CV_EXPORTS
SCascade
:
public
Algorithm
class
CV_EXPORTS
_W
SCascade
:
public
Algorithm
{
public:
...
...
@@ -539,24 +539,27 @@ public:
// Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed.
// Param scales is a number of scales from minScale to maxScale.
// Param rejfactor is used for NMS.
SCascade
(
const
double
minScale
=
0.4
,
const
double
maxScale
=
5.
,
const
int
scales
=
55
,
const
int
rejfactor
=
1
);
CV_WRAP
SCascade
(
const
double
minScale
=
0.4
,
const
double
maxScale
=
5.
,
const
int
scales
=
55
,
const
int
rejfactor
=
1
);
virtual
~
SCascade
();
CV_WRAP
virtual
~
SCascade
();
cv
::
AlgorithmInfo
*
info
()
const
;
// Load cascade from FileNode.
// Param fn is a root node for cascade. Should be <cascade>.
virtual
bool
load
(
const
FileNode
&
fn
);
CV_WRAP
virtual
bool
load
(
const
FileNode
&
fn
);
// Load cascade config.
virtual
void
read
(
const
FileNode
&
fn
);
CV_WRAP
virtual
void
read
(
const
FileNode
&
fn
);
// Return the vector of Decection objcts.
// Param image is a frame on which detector will be applied.
// Param rois is a vector of regions of interest. Only the objects that fall into one of the regions will be returned.
// Param objects is an output array of Detections
virtual
void
detect
(
InputArray
image
,
InputArray
rois
,
std
::
vector
<
Detection
>&
objects
)
const
;
// Param rects is an output array of bounding rectangles for detected objects.
// Param confs is an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th configence.
CV_WRAP
virtual
void
detect
(
InputArray
image
,
InputArray
rois
,
OutputArray
rects
,
OutputArray
confs
)
const
;
private:
void
detectNoRoi
(
const
Mat
&
image
,
std
::
vector
<
Detection
>&
objects
)
const
;
...
...
modules/objdetect/src/softcascade.cpp
浏览文件 @
bd9ca48f
...
...
@@ -500,4 +500,27 @@ void cv::SCascade::detect(cv::InputArray _image, cv::InputArray _rois, std::vect
}
}
}
}
void
cv
::
SCascade
::
detect
(
InputArray
_image
,
InputArray
_rois
,
OutputArray
_rects
,
OutputArray
_confs
)
const
{
std
::
vector
<
Detection
>
objects
;
detect
(
_image
,
_rois
,
objects
);
_rects
.
create
(
1
,
objects
.
size
(),
CV_32SC4
);
cv
::
Mat_
<
cv
::
Rect
>
rects
=
(
cv
::
Mat_
<
cv
::
Rect
>
)
_rects
.
getMat
();
cv
::
Rect
*
rectPtr
=
rects
.
ptr
<
cv
::
Rect
>
(
0
);
_confs
.
create
(
1
,
objects
.
size
(),
CV_32F
);
cv
::
Mat
confs
=
_confs
.
getMat
();
float
*
confPtr
=
rects
.
ptr
<
float
>
(
0
);
typedef
std
::
vector
<
Detection
>::
const_iterator
IDet
;
int
i
=
0
;
for
(
IDet
it
=
objects
.
begin
();
it
!=
objects
.
end
();
++
it
,
++
i
)
{
rectPtr
[
i
]
=
(
*
it
).
bb
;
confPtr
[
i
]
=
(
*
it
).
confidence
;
}
}
\ No newline at end of file
modules/objdetect/test/test_softcascade.cpp
浏览文件 @
bd9ca48f
...
...
@@ -66,34 +66,26 @@ TEST(SCascade, detect)
std
::
vector
<
Detection
>
objects
;
cascade
.
detect
(
colored
,
cv
::
noArray
(),
objects
);
// cv::Mat out = colored.clone();
// int level = 0, total = 0;
// int levelWidth = objects[0].bb.width;
// for(int i = 0 ; i < (int)objects.size(); ++i)
// {
// if (objects[i].bb.width != levelWidth)
// {
// std::cout << "Level: " << level << " total " << total << std::endl;
// cv::imshow("out", out);
// cv::waitKey(0);
// out = colored.clone();
// levelWidth = objects[i].bb.width;
// total = 0;
// level++;
// }
// cv::rectangle(out, objects[i].bb, cv::Scalar(255, 0, 0, 255), 1);
// std::cout << "detection: " << objects[i].bb.x
// << " " << objects[i].bb.y
// << " " << objects[i].bb.width
// << " " << objects[i].bb.height << std::endl;
// total++;
// }
// std::cout << "detected: " << (int)objects.size() << std::endl;
ASSERT_EQ
((
int
)
objects
.
size
(),
3498
);
}
TEST
(
SCascade
,
detectSeparate
)
{
typedef
cv
::
SCascade
::
Detection
Detection
;
std
::
string
xml
=
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"cascadeandhog/sc_cvpr_2012_to_opencv.xml"
;
cv
::
SCascade
cascade
;
cv
::
FileStorage
fs
(
xml
,
cv
::
FileStorage
::
READ
);
ASSERT_TRUE
(
cascade
.
load
(
fs
.
getFirstTopLevelNode
()));
cv
::
Mat
colored
=
cv
::
imread
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"cascadeandhog/bahnhof/image_00000000_0.png"
);
ASSERT_FALSE
(
colored
.
empty
());
cv
::
Mat
rects
,
confs
;
cascade
.
detect
(
colored
,
cv
::
noArray
(),
rects
,
confs
);
ASSERT_EQ
(
confs
.
cols
,
3498
);
}
TEST
(
SCascade
,
detectRoi
)
{
typedef
cv
::
SCascade
::
Detection
Detection
;
...
...
@@ -110,31 +102,6 @@ TEST(SCascade, detectRoi)
rois
.
push_back
(
cv
::
Rect
(
0
,
0
,
640
,
480
));
cascade
.
detect
(
colored
,
rois
,
objects
);
// cv::Mat out = colored.clone();
// int level = 0, total = 0;
// int levelWidth = objects[0].bb.width;
// for(int i = 0 ; i < (int)objects.size(); ++i)
// {
// if (objects[i].bb.width != levelWidth)
// {
// std::cout << "Level: " << level << " total " << total << std::endl;
// cv::imshow("out", out);
// cv::waitKey(0);
// out = colored.clone();
// levelWidth = objects[i].bb.width;
// total = 0;
// level++;
// }
// cv::rectangle(out, objects[i].bb, cv::Scalar(255, 0, 0, 255), 1);
// std::cout << "detection: " << objects[i].bb.x
// << " " << objects[i].bb.y
// << " " << objects[i].bb.width
// << " " << objects[i].bb.height << std::endl;
// total++;
// }
// std::cout << "detected: " << (int)objects.size() << std::endl;
ASSERT_EQ
((
int
)
objects
.
size
(),
3498
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录