Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
ff8417db
Commit
ff8417db
authored
Nov 01, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove input frame size constraints
parent
3cb9afb4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
87 deletions
+46
-87
perf_cascadeclassifier.cpp
modules/objdetect/perf/perf_cascadeclassifier.cpp
+17
-1
isf.cpp
modules/objdetect/src/isf.cpp
+3
-45
softcascade.cpp
modules/objdetect/src/softcascade.cpp
+1
-17
test_softcascade.cpp
modules/objdetect/test/test_softcascade.cpp
+25
-24
No files found.
modules/objdetect/perf/perf_cascadeclassifier.cpp
View file @
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
View file @
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
View file @
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
View file @
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment