Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
56517437
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,发现更多精彩内容 >>
提交
56517437
编写于
10月 06, 2012
作者:
M
marina.kolpakova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove debug imshow from code
上级
8e092f8b
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
40 addition
and
41 deletion
+40
-41
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+2
-0
modules/objdetect/src/softcascade.cpp
modules/objdetect/src/softcascade.cpp
+8
-36
modules/objdetect/test/test_softcascade.cpp
modules/objdetect/test/test_softcascade.cpp
+30
-5
未找到文件。
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
浏览文件 @
56517437
...
...
@@ -501,6 +501,8 @@ public:
int
kind
;
enum
{
PEDESTRIAN
=
0
};
Detection
(
const
cv
::
Rect
&
r
,
const
float
c
,
int
k
=
PEDESTRIAN
)
:
rect
(
r
),
confidence
(
c
),
kind
(
k
)
{}
};
//! An empty cascade will be created.
...
...
modules/objdetect/src/softcascade.cpp
浏览文件 @
56517437
...
...
@@ -204,6 +204,7 @@ struct Level
enum
{
R_SHIFT
=
1
<<
15
};
float
scaling
[
2
];
typedef
cv
::
SoftCascade
::
Detection
detection_t
;
Level
(
const
Octave
&
oct
,
const
float
scale
,
const
int
shrinkage
,
const
int
w
,
const
int
h
)
:
octave
(
&
oct
),
origScale
(
scale
),
relScale
(
scale
/
oct
.
scale
),
shrScale
(
relScale
/
(
float
)
shrinkage
),
...
...
@@ -215,12 +216,12 @@ struct Level
scaleshift
=
relScale
*
(
1
<<
16
);
}
void
markDetection
(
const
int
x
,
const
int
y
,
float
confidence
,
std
::
vector
<
Objec
t
>&
detections
)
const
void
markDetection
(
const
int
x
,
const
int
y
,
float
confidence
,
std
::
vector
<
detection_
t
>&
detections
)
const
{
int
shrinkage
=
(
*
octave
).
shrinkage
;
cv
::
Rect
rect
(
cvRound
(
x
*
shrinkage
),
cvRound
(
y
*
shrinkage
),
objSize
.
width
,
objSize
.
height
);
detections
.
push_back
(
Objec
t
(
rect
,
confidence
));
detections
.
push_back
(
detection_
t
(
rect
,
confidence
));
}
float
rescale
(
cv
::
Rect
&
scaledRect
,
const
float
threshold
,
int
idx
)
const
...
...
@@ -432,7 +433,8 @@ struct cv::SoftCascade::Filds
typedef
std
::
vector
<
Octave
>::
iterator
octIt_t
;
void
detectAt
(
const
int
dx
,
const
int
dy
,
const
Level
&
level
,
const
ChannelStorage
&
storage
,
std
::
vector
<
Object
>&
detections
)
const
void
detectAt
(
const
int
dx
,
const
int
dy
,
const
Level
&
level
,
const
ChannelStorage
&
storage
,
std
::
vector
<
Detection
>&
detections
)
const
{
dprintf
(
"detect at: %d %d
\n
"
,
dx
,
dy
);
...
...
@@ -685,12 +687,11 @@ bool cv::SoftCascade::load( const string& filename, const float minScale, const
return
true
;
}
#define DEBUG_SHOW_RESULT
void
cv
::
SoftCascade
::
detectMultiScale
(
const
Mat
&
image
,
const
std
::
vector
<
cv
::
Rect
>&
/*rois*/
,
std
::
vector
<
Detection
>&
objects
,
const
int
/*rejectfactor*/
)
const
{
typedef
std
::
vector
<
cv
::
Rect
>::
const_iterator
RIter_t
;
// only color images are supperted
CV_Assert
(
image
.
type
()
==
CV_8UC3
);
...
...
@@ -704,49 +705,20 @@ void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector<cv::R
// create integrals
ChannelStorage
storage
(
image
,
fld
.
shrinkage
);
// object candidates
std
::
vector
<
Object
>
detections
;
typedef
std
::
vector
<
Level
>::
const_iterator
lIt
;
int
total
=
0
,
l
=
0
;
for
(
lIt
it
=
fld
.
levels
.
begin
();
it
!=
fld
.
levels
.
end
();
++
it
)
{
const
Level
&
level
=
*
it
;
#if defined WITH_DEBUG_OUT
std
::
cout
<<
"================================ "
<<
l
++
<<
std
::
endl
;
#else
(
void
)
l
;
#endif
// int dx = 79; int dy = 76;
for
(
int
dy
=
0
;
dy
<
level
.
workRect
.
height
;
++
dy
)
{
for
(
int
dx
=
0
;
dx
<
level
.
workRect
.
width
;
++
dx
)
{
storage
.
offset
=
dy
*
storage
.
step
+
dx
;
fld
.
detectAt
(
dx
,
dy
,
level
,
storage
,
detections
);
total
++
;
fld
.
detectAt
(
dx
,
dy
,
level
,
storage
,
objects
);
}
}
#if defined DEBUG_SHOW_RESULT
cv
::
Mat
out
=
image
.
clone
();
printf
(
"TOTAL: %d from %d
\n
"
,
(
int
)
detections
.
size
(),
total
)
;
for
(
int
i
=
0
;
i
<
(
int
)
detections
.
size
();
++
i
)
{
cv
::
rectangle
(
out
,
detections
[
i
].
rect
,
cv
::
Scalar
(
255
,
0
,
0
,
255
),
1
);
}
cv
::
imshow
(
"out"
,
out
);
cv
::
waitKey
(
0
);
std
::
cout
<<
"work rect: "
<<
level
.
workRect
.
width
<<
" "
<<
level
.
workRect
.
height
<<
std
::
endl
;
#endif
detections
.
clear
();
}
// std::swap(detections, objects);
}
\ No newline at end of file
modules/objdetect/test/test_softcascade.cpp
浏览文件 @
56517437
...
...
@@ -59,11 +59,36 @@ TEST(SoftCascade, detect)
cv
::
Mat
colored
=
cv
::
imread
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"cascadeandhog/bahnhof/image_00000000_0.png"
);
ASSERT_FALSE
(
colored
.
empty
());
std
::
vector
<
detection_t
>
object
Boxe
s
;
std
::
vector
<
detection_t
>
objects
;
std
::
vector
<
cv
::
Rect
>
rois
;
rois
.
push_back
(
cv
::
Rect
(
0
,
0
,
640
,
480
));
// ASSERT_NO_THROW(
// {
cascade
.
detectMultiScale
(
colored
,
rois
,
objectBoxes
);
// });
cascade
.
detectMultiScale
(
colored
,
rois
,
objects
);
std
::
cout
<<
"detected: "
<<
(
int
)
objects
.
size
()
<<
std
::
endl
;
cv
::
Mat
out
=
colored
.
clone
();
int
level
=
0
,
total
=
0
;
int
levelWidth
=
objects
[
0
].
rect
.
width
;
for
(
int
i
=
0
;
i
<
(
int
)
objects
.
size
();
++
i
)
{
if
(
objects
[
i
].
rect
.
width
!=
levelWidth
)
{
std
::
cout
<<
"Level: "
<<
level
<<
" total "
<<
total
<<
std
::
endl
;
cv
::
imshow
(
"out"
,
out
);
cv
::
waitKey
(
0
);
out
=
colored
.
clone
();
levelWidth
=
objects
[
i
].
rect
.
width
;
total
=
0
;
level
++
;
}
cv
::
rectangle
(
out
,
objects
[
i
].
rect
,
cv
::
Scalar
(
255
,
0
,
0
,
255
),
1
);
std
::
cout
<<
"detection: "
<<
objects
[
i
].
rect
.
x
<<
" "
<<
objects
[
i
].
rect
.
y
<<
" "
<<
objects
[
i
].
rect
.
width
<<
" "
<<
objects
[
i
].
rect
.
height
<<
std
::
endl
;
total
++
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录