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
c04725b6
Commit
c04725b6
authored
Sep 05, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add apply cascade method
parent
69582705
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
15 deletions
+39
-15
CMakeLists.txt
modules/gpu/CMakeLists.txt
+0
-0
objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+0
-1
softcascade.cpp
modules/objdetect/src/softcascade.cpp
+35
-11
test_softcascade.cpp
modules/objdetect/test/test_softcascade.cpp
+4
-3
No files found.
modules/gpu/CMakeLists.txt
View file @
c04725b6
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
View file @
c04725b6
...
@@ -507,7 +507,6 @@ public:
...
@@ -507,7 +507,6 @@ public:
int
step
=
4
,
int
rejectfactor
=
1
);
int
step
=
4
,
int
rejectfactor
=
1
);
protected
:
protected
:
virtual
void
detectInRoi
();
virtual
void
detectForOctave
(
int
octave
);
virtual
void
detectForOctave
(
int
octave
);
// virtual bool detectSingleScale( const Mat& image, int stripCount, Size processingRectSize,
// virtual bool detectSingleScale( const Mat& image, int stripCount, Size processingRectSize,
// int stripSize, int yStep, double factor, vector<Rect>& candidates,
// int stripSize, int yStep, double factor, vector<Rect>& candidates,
...
...
modules/objdetect/src/softcascade.cpp
View file @
c04725b6
...
@@ -164,6 +164,15 @@ namespace {
...
@@ -164,6 +164,15 @@ namespace {
float
relScale
()
{
return
(
factor
/
octave
);
}
float
relScale
()
{
return
(
factor
/
octave
);
}
};
};
struct
Integral
{
cv
::
Mat
magnitude
;
std
::
vector
<
cv
::
Mat
>
hist
;
cv
::
Mat
luv
;
Integral
(
cv
::
Mat
m
,
std
::
vector
<
cv
::
Mat
>
h
,
cv
::
Mat
l
)
:
magnitude
(
m
),
hist
(
h
),
luv
(
l
)
{}
};
}
}
struct
cv
::
SoftCascade
::
Filds
struct
cv
::
SoftCascade
::
Filds
...
@@ -181,6 +190,26 @@ struct cv::SoftCascade::Filds
...
@@ -181,6 +190,26 @@ struct cv::SoftCascade::Filds
std
::
vector
<
Feature
>
features
;
std
::
vector
<
Feature
>
features
;
std
::
vector
<
Level
>
levels
;
std
::
vector
<
Level
>
levels
;
typedef
std
::
vector
<
Stage
>::
iterator
stIter_t
;
// carrently roi must be save for out of ranges.
void
detectInRoi
(
const
cv
::
Rect
&
roi
,
const
Integral
&
ints
,
std
::
vector
<
cv
::
Rect
>&
objects
,
const
int
step
)
{
for
(
int
dy
=
roi
.
y
;
dy
<
roi
.
height
;
dy
+=
step
)
for
(
int
dx
=
roi
.
x
;
dx
<
roi
.
width
;
dx
+=
step
)
{
applyCascade
(
ints
,
dx
,
dy
);
}
}
void
applyCascade
(
const
Integral
&
ints
,
const
int
x
,
const
int
y
)
{
for
(
stIter_t
sIt
=
sIt
.
begin
();
sIt
!=
stages
.
end
();
++
sIt
)
{
Stage
stage
&
=
*
sIt
;
}
}
// compute levels of full pyramid
// compute levels of full pyramid
void
calcLevels
(
int
frameW
,
int
frameH
,
int
scales
)
void
calcLevels
(
int
frameW
,
int
frameH
,
int
scales
)
{
{
...
@@ -327,7 +356,7 @@ bool cv::SoftCascade::load( const string& filename, const float minScale, const
...
@@ -327,7 +356,7 @@ bool cv::SoftCascade::load( const string& filename, const float minScale, const
namespace
{
namespace
{
void
calcHistBins
(
const
cv
::
Mat
&
grey
,
std
::
vector
<
cv
::
Mat
>&
histInts
,
const
int
bins
)
void
calcHistBins
(
const
cv
::
Mat
&
grey
,
cv
::
Mat
magIntegral
,
std
::
vector
<
cv
::
Mat
>&
histInts
,
const
int
bins
)
{
{
CV_Assert
(
grey
.
type
()
==
CV_8U
);
CV_Assert
(
grey
.
type
()
==
CV_8U
);
const
int
rows
=
grey
.
rows
+
1
;
const
int
rows
=
grey
.
rows
+
1
;
...
@@ -368,18 +397,10 @@ namespace {
...
@@ -368,18 +397,10 @@ namespace {
histInts
.
push_back
(
sum
);
histInts
.
push_back
(
sum
);
}
}
cv
::
Mat
magIntegral
;
cv
::
integral
(
mag
,
magIntegral
,
mag
.
depth
());
cv
::
integral
(
mag
,
magIntegral
,
mag
.
depth
());
}
}
struct
Integrals
{
/* data */
};
}
}
void
cv
::
SoftCascade
::
detectInRoi
()
{}
void
cv
::
SoftCascade
::
detectMultiScale
(
const
Mat
&
image
,
const
std
::
vector
<
cv
::
Rect
>&
rois
,
std
::
vector
<
cv
::
Rect
>&
objects
,
void
cv
::
SoftCascade
::
detectMultiScale
(
const
Mat
&
image
,
const
std
::
vector
<
cv
::
Rect
>&
rois
,
std
::
vector
<
cv
::
Rect
>&
objects
,
...
@@ -405,13 +426,16 @@ void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector<cv::R
...
@@ -405,13 +426,16 @@ void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector<cv::R
cv
::
cvtColor
(
image
,
grey
,
CV_RGB2GRAY
);
cv
::
cvtColor
(
image
,
grey
,
CV_RGB2GRAY
);
std
::
vector
<
cv
::
Mat
>
hist
;
std
::
vector
<
cv
::
Mat
>
hist
;
cv
::
Mat
magnitude
;
const
int
bins
=
6
;
const
int
bins
=
6
;
calcHistBins
(
grey
,
hist
,
bins
);
calcHistBins
(
grey
,
magnitude
,
hist
,
bins
);
Integral
integrals
(
magnitude
,
hist
,
luv
);
for
(
RIter_t
it
=
rois
.
begin
();
it
!=
rois
.
end
();
++
it
)
for
(
RIter_t
it
=
rois
.
begin
();
it
!=
rois
.
end
();
++
it
)
{
{
const
cv
::
Rect
&
roi
=
*
it
;
const
cv
::
Rect
&
roi
=
*
it
;
// detectInRoi(roi
, objects, step);
(
*
filds
).
detectInRoi
(
roi
,
integrals
,
objects
,
step
);
}
}
}
}
...
...
modules/objdetect/test/test_softcascade.cpp
View file @
c04725b6
...
@@ -62,8 +62,8 @@ TEST(SoftCascade, Detect)
...
@@ -62,8 +62,8 @@ TEST(SoftCascade, Detect)
std
::
vector
<
cv
::
Rect
>
objectBoxes
;
std
::
vector
<
cv
::
Rect
>
objectBoxes
;
std
::
vector
<
cv
::
Rect
>
rois
;
std
::
vector
<
cv
::
Rect
>
rois
;
rois
.
push_back
(
cv
::
Rect
(
0
,
0
,
640
,
480
));
rois
.
push_back
(
cv
::
Rect
(
0
,
0
,
640
,
480
));
ASSERT_NO_THROW
(
//
ASSERT_NO_THROW(
{
//
{
cascade
.
detectMultiScale
(
colored
,
rois
,
objectBoxes
);
cascade
.
detectMultiScale
(
colored
,
rois
,
objectBoxes
);
});
//
});
}
}
\ 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