Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
ff8417db
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,发现更多精彩内容 >>
提交
ff8417db
编写于
11月 01, 2012
作者:
M
marina.kolpakova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove input frame size constraints
上级
3cb9afb4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
87 deletion
+45
-87
modules/objdetect/perf/perf_cascadeclassifier.cpp
modules/objdetect/perf/perf_cascadeclassifier.cpp
+17
-1
modules/objdetect/src/isf.cpp
modules/objdetect/src/isf.cpp
+3
-45
modules/objdetect/src/softcascade.cpp
modules/objdetect/src/softcascade.cpp
+1
-17
modules/objdetect/test/test_softcascade.cpp
modules/objdetect/test/test_softcascade.cpp
+24
-24
未找到文件。
modules/objdetect/perf/perf_cascadeclassifier.cpp
浏览文件 @
ff8417db
...
...
@@ -56,6 +56,18 @@ PERF_TEST_P(ImageName_MinSize, CascadeClassifierLBPFrontalFace,
typedef
std
::
tr1
::
tuple
<
std
::
string
,
std
::
string
>
fixture
;
typedef
perf
::
TestBaseWithParam
<
fixture
>
detect
;
namespace
{
typedef
cv
::
SoftCascade
::
Detection
detection_t
;
void
extractRacts
(
std
::
vector
<
detection_t
>
objectBoxes
,
vector
<
Rect
>
rects
)
{
rects
.
clear
();
for
(
int
i
=
0
;
i
<
(
int
)
objectBoxes
.
size
();
++
i
)
rects
.
push_back
(
objectBoxes
[
i
].
rect
);
}
}
PERF_TEST_P
(
detect
,
SoftCascade
,
testing
::
Combine
(
testing
::
Values
(
std
::
string
(
"cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml"
)),
testing
::
Values
(
std
::
string
(
"cv/cascadeandhog/bahnhof/image_00000000_0.png"
))))
...
...
@@ -76,5 +88,9 @@ PERF_TEST_P(detect, SoftCascade,
{
cascade
.
detectMultiScale
(
colored
,
rois
,
objectBoxes
);
}
SANITY_CHECK
(
objectBoxes
);
vector
<
Rect
>
rects
;
extractRacts
(
objectBoxes
,
rects
);
std
::
sort
(
rects
.
begin
(),
rects
.
end
(),
comparators
::
RectLess
());
SANITY_CHECK
(
rects
);
}
modules/objdetect/src/isf.cpp
浏览文件 @
ff8417db
...
...
@@ -44,44 +44,6 @@
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/core/core.hpp>
template
<
typename
T
>
struct
Decimate
{
int
shrinkage
;
Decimate
(
const
int
sr
)
:
shrinkage
(
sr
)
{}
void
operator
()(
const
cv
::
Mat
&
in
,
cv
::
Mat
&
out
)
const
{
int
cols
=
in
.
cols
/
shrinkage
;
int
rows
=
in
.
rows
/
shrinkage
;
out
.
create
(
rows
,
cols
,
in
.
type
());
CV_Assert
(
cols
*
shrinkage
==
in
.
cols
);
CV_Assert
(
rows
*
shrinkage
==
in
.
rows
);
for
(
int
outIdx_y
=
0
;
outIdx_y
<
rows
;
++
outIdx_y
)
{
T
*
outPtr
=
out
.
ptr
<
T
>
(
outIdx_y
);
for
(
int
outIdx_x
=
0
;
outIdx_x
<
cols
;
++
outIdx_x
)
{
// do desimate
int
inIdx_y
=
outIdx_y
*
shrinkage
;
int
inIdx_x
=
outIdx_x
*
shrinkage
;
int
sum
=
0
;
for
(
int
y
=
inIdx_y
;
y
<
inIdx_y
+
shrinkage
;
++
y
)
for
(
int
x
=
inIdx_x
;
x
<
inIdx_x
+
shrinkage
;
++
x
)
sum
+=
in
.
at
<
T
>
(
y
,
x
);
sum
/=
shrinkage
*
shrinkage
;
outPtr
[
outIdx_x
]
=
cv
::
saturate_cast
<
T
>
(
sum
);
}
}
}
};
void
cv
::
IntegralChannels
::
createHogBins
(
const
cv
::
Mat
gray
,
std
::
vector
<
cv
::
Mat
>&
integrals
,
int
bins
)
const
{
CV_Assert
(
gray
.
type
()
==
CV_8UC1
);
...
...
@@ -89,8 +51,6 @@ void cv::IntegralChannels::createHogBins(const cv::Mat gray, std::vector<cv::Mat
int
w
=
gray
.
cols
;
CV_Assert
(
!
(
w
%
shrinkage
)
&&
!
(
h
%
shrinkage
));
Decimate
<
uchar
>
decimate
(
shrinkage
);
cv
::
Mat
df_dx
,
df_dy
,
mag
,
angle
;
cv
::
Sobel
(
gray
,
df_dx
,
CV_32F
,
1
,
0
,
3
,
0.125
);
cv
::
Sobel
(
gray
,
df_dy
,
CV_32F
,
0
,
1
,
3
,
0.125
);
...
...
@@ -121,13 +81,13 @@ void cv::IntegralChannels::createHogBins(const cv::Mat gray, std::vector<cv::Mat
for
(
int
i
=
0
;
i
<
bins
;
++
i
)
{
cv
::
Mat
shrunk
,
sum
;
decimate
(
hist
[
i
],
shrunk
);
cv
::
resize
(
hist
[
i
],
shrunk
,
cv
::
Size
(),
1.0
/
shrinkage
,
1.0
/
shrinkage
,
CV_INTER_AREA
);
cv
::
integral
(
shrunk
,
sum
,
cv
::
noArray
(),
CV_32S
);
integrals
.
push_back
(
sum
);
}
cv
::
Mat
shrMag
;
decimate
(
nmag
,
shrMag
);
cv
::
resize
(
nmag
,
shrMag
,
cv
::
Size
(),
1.0
/
shrinkage
,
1.0
/
shrinkage
,
CV_INTER_AREA
);
cv
::
integral
(
shrMag
,
mag
,
cv
::
noArray
(),
CV_32S
);
integrals
.
push_back
(
mag
);
}
...
...
@@ -137,8 +97,6 @@ void cv::IntegralChannels::createLuvBins(const cv::Mat frame, std::vector<cv::Ma
CV_Assert
(
frame
.
type
()
==
CV_8UC3
);
CV_Assert
(
!
(
frame
.
cols
%
shrinkage
)
&&
!
(
frame
.
rows
%
shrinkage
));
Decimate
<
uchar
>
decimate
(
shrinkage
);
cv
::
Mat
luv
;
cv
::
cvtColor
(
frame
,
luv
,
CV_BGR2Luv
);
...
...
@@ -148,7 +106,7 @@ void cv::IntegralChannels::createLuvBins(const cv::Mat frame, std::vector<cv::Ma
for
(
size_t
i
=
0
;
i
<
splited
.
size
();
++
i
)
{
cv
::
Mat
shrunk
,
sum
;
decimate
(
splited
[
i
],
shrunk
);
cv
::
resize
(
splited
[
i
],
shrunk
,
cv
::
Size
(),
1.0
/
shrinkage
,
1.0
/
shrinkage
,
CV_INTER_AREA
);
cv
::
integral
(
shrunk
,
sum
,
cv
::
noArray
(),
CV_32S
);
integrals
.
push_back
(
sum
);
}
...
...
modules/objdetect/src/softcascade.cpp
浏览文件 @
ff8417db
...
...
@@ -396,16 +396,6 @@ struct cv::SoftCascade::Filds
if
(
fabs
(
scale
-
maxScale
)
<
FLT_EPSILON
)
break
;
scale
=
std
::
min
(
maxScale
,
expf
(
log
(
scale
)
+
logFactor
));
std
::
cout
<<
"level "
<<
sc
<<
" scale "
<<
levels
[
sc
].
origScale
<<
" octeve "
<<
levels
[
sc
].
octave
->
scale
<<
" "
<<
levels
[
sc
].
relScale
<<
" ["
<<
levels
[
sc
].
objSize
.
width
<<
" "
<<
levels
[
sc
].
objSize
.
height
<<
"] ["
<<
levels
[
sc
].
workRect
.
width
<<
" "
<<
levels
[
sc
].
workRect
.
height
<<
"]"
<<
std
::
endl
;
}
}
...
...
@@ -523,10 +513,7 @@ bool cv::SoftCascade::read( const cv::FileStorage& fs)
filds
=
new
Filds
;
Filds
&
flds
=
*
filds
;
if
(
!
flds
.
fill
(
fs
.
getFirstTopLevelNode
(),
minScale
,
maxScale
))
return
false
;
// flds.calcLevels(FRAME_WIDTH, FRAME_HEIGHT, scales);
return
true
;
return
flds
.
fill
(
fs
.
getFirstTopLevelNode
(),
minScale
,
maxScale
);
}
void
cv
::
SoftCascade
::
detectMultiScale
(
const
Mat
&
image
,
const
std
::
vector
<
cv
::
Rect
>&
/*rois*/
,
...
...
@@ -535,9 +522,6 @@ void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector<cv::R
// only color images are supperted
CV_Assert
(
image
.
type
()
==
CV_8UC3
);
// only this window size allowed
CV_Assert
(
image
.
cols
==
640
&&
image
.
rows
==
480
);
Filds
&
fld
=
*
filds
;
fld
.
calcLevels
(
image
.
size
(),
scales
);
...
...
modules/objdetect/test/test_softcascade.cpp
浏览文件 @
ff8417db
...
...
@@ -68,29 +68,29 @@ TEST(SoftCascade, detect)
cascade
.
detectMultiScale
(
colored
,
rois
,
objects
);
cv
::
Mat
out
=
colored
.
clone
();
int
level
=
0
,
total
=
0
;
int
levelWidth
=
objects
[
0
].
rect
.
width
;
//
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
++
;
}
std
::
cout
<<
"detected: "
<<
(
int
)
objects
.
size
()
<<
std
::
endl
;
ASSERT_EQ
((
int
)
objects
.
size
(),
1469
);
//
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++;
//
}
//
std::cout << "detected: " << (int)objects.size() << std::endl;
ASSERT_EQ
((
int
)
objects
.
size
(),
3668
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录