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
fb113e5c
Commit
fb113e5c
authored
Aug 30, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scale pyramid calculations
parent
cd301e53
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
10 deletions
+131
-10
objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+2
-1
softcascade.cpp
modules/objdetect/src/softcascade.cpp
+129
-9
No files found.
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
View file @
fb113e5c
...
...
@@ -506,6 +506,7 @@ protected:
// int stripSize, int yStep, double factor, vector<Rect>& candidates,
// vector<int>& rejectLevels, vector<double>& levelWeights, bool outputRejectLevels=false);
enum
{
BOOST
=
0
};
enum
{
FRAME_WIDTH
=
640
,
FRAME_HEIGHT
=
480
,
TOTAL_SCALES
=
55
,
CLASSIFIERS
=
5
};
private
:
struct
Feature
...
...
@@ -514,7 +515,7 @@ private:
int
channel
;
};
stuct
Stamp
st
r
uct
Stamp
{
};
...
...
modules/objdetect/src/softcascade.cpp
View file @
fb113e5c
...
...
@@ -39,8 +39,15 @@
// the use of this software, even if advised of the possibility of such damage.
//M*/
struct
Filds
#include <precomp.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <vector>
struct
cv
::
SoftCascade
::
Filds
{
std
::
vector
<
float
>
octaves
;
// cv::Mat luv;
// std::vector<cv::Mat> bins;
// cv::Mat magnitude;
...
...
@@ -48,27 +55,139 @@ struct Filds
// int windowStep;
};
namespace
{
struct
Cascade
{
int
logOctave
;
float
octave
;
cv
::
Size
objSize
;
};
struct
Level
{
int
index
;
float
factor
;
float
logFactor
;
int
width
;
int
height
;
float
octave
;
cv
::
Size
objSize
;
Level
(
int
i
,
float
f
,
float
lf
,
int
w
,
int
h
)
:
index
(
i
),
factor
(
f
),
logFactor
(
lf
),
width
(
w
),
height
(
h
),
octave
(
0.
f
)
{}
void
assign
(
float
o
,
int
detW
,
int
detH
)
{
octave
=
o
;
objSize
=
cv
::
Size
(
cv
::
saturate_cast
<
int
>
(
detW
*
o
),
cv
::
saturate_cast
<
int
>
(
detH
*
o
));
}
float
relScale
()
{
return
(
factor
/
octave
);
}
};
// compute levels of full pyramid
void
pyrLevels
(
int
frameW
,
int
frameH
,
int
detW
,
int
detH
,
int
scales
,
float
minScale
,
float
maxScale
,
std
::
vector
<
Level
>
levels
)
{
CV_Assert
(
scales
>
1
);
levels
.
clear
();
float
logFactor
=
(
log
(
maxScale
)
-
log
(
minScale
))
/
(
scales
-
1
);
float
scale
=
minScale
;
for
(
int
sc
=
0
;
sc
<
scales
;
++
sc
)
{
Level
level
(
sc
,
scale
,
log
(
scale
)
+
logFactor
,
std
::
max
(
0.0
f
,
frameW
-
(
detW
*
scale
)),
std
::
max
(
0.0
f
,
frameH
-
(
detH
*
scale
)));
if
(
!
level
.
width
||
!
level
.
height
)
break
;
else
levels
.
push_back
(
level
);
if
(
fabs
(
scale
-
maxScale
)
<
FLT_EPSILON
)
break
;
scale
=
std
::
min
(
maxScale
,
expf
(
log
(
scale
)
+
logFactor
));
}
}
// according to R. Benenson, M. Mathias, R. Timofte and L. Van Gool paper
struct
CascadeIntrinsics
{
static
const
float
lambda
=
1.099
f
/
0.301029996
f
,
a
=
0.89
f
;
static
const
float
intrinsics
[
10
][
4
];
SoftCascade
::
SoftCascade
()
:
filds
(
0
)
{}
static
float
getFor
(
int
chennel
,
int
scaling
,
int
ab
)
{
CV_Assert
(
chennel
<
10
&&
scaling
<
2
&&
ab
<
2
);
return
intrinsics
[
chennel
][(
scaling
<<
1
)
+
ab
];
}
SoftCascade
::
SoftCascade
(
const
string
&
filename
)
};
const
float
CascadeIntrinsics
::
intrinsics
[
10
][
4
]
=
{
//da, db, ua, ub
// hog-like orientation bins
{
a
,
lambda
,
1
,
2
},
{
a
,
lambda
,
1
,
2
},
{
a
,
lambda
,
1
,
2
},
{
a
,
lambda
,
1
,
2
},
{
a
,
lambda
,
1
,
2
},
{
a
,
lambda
,
1
,
2
},
// gradient magnitude
{
a
,
lambda
/
log
(
2
),
1
,
2
},
// luv -color chennels
{
1
,
2
,
1
,
2
},
{
1
,
2
,
1
,
2
},
{
1
,
2
,
1
,
2
}
};
}
cv
::
SoftCascade
::
SoftCascade
()
:
filds
(
0
)
{}
cv
::
SoftCascade
::
SoftCascade
(
const
string
&
filename
)
{
filds
=
new
f
ilds
;
filds
=
new
F
ilds
;
load
(
filename
);
}
virtual
SoftCascade
::~
SoftCascade
()
cv
::
SoftCascade
::~
SoftCascade
()
{
delete
filds
;
}
bool
SoftCascade
::
load
(
const
string
&
filename
)
bool
cv
::
SoftCascade
::
load
(
const
string
&
filename
)
{
// temp fixture
Filds
&
flds
=
*
filds
;
flds
.
octaves
.
push_back
(
0.5
f
);
flds
.
octaves
.
push_back
(
1.0
f
);
flds
.
octaves
.
push_back
(
2.0
f
);
flds
.
octaves
.
push_back
(
4.0
f
);
flds
.
octaves
.
push_back
(
8.0
f
);
// scales calculations
int
origObjectW
=
64
;
int
origObjectH
=
128
;
float
maxScale
=
5.
f
,
minScale
=
0.4
f
;
std
::
vector
<
Level
>
levels
;
pyrLevels
(
FRAME_WIDTH
,
FRAME_HEIGHT
,
origObjectW
,
origObjectH
,
TOTAL_SCALES
,
minScale
,
maxScale
,
levels
);
for
(
std
::
vector
<
Level
>::
iterator
level
=
levels
.
begin
();
level
<
levels
.
end
();
++
level
)
{
float
minAbsLog
=
FLT_MAX
;
for
(
std
::
vector
<
float
>::
iterator
oct
=
flds
.
octaves
.
begin
();
oct
<
flds
.
octaves
.
end
();
++
oct
)
{
float
logOctave
=
log
(
*
oct
);
float
logAbsScale
=
fabs
((
*
level
).
logFactor
-
logOctave
);
if
(
logAbsScale
<
minAbsLog
)
(
*
level
).
assign
(
*
oct
,
origObjectW
,
origObjectH
);
}
}
return
true
;
}
v
irtual
void
SoftCascade
::
detectMultiScale
(
const
Mat
&
image
,
const
std
::
vector
<
cv
::
Rect
>&
rois
,
std
::
vector
<
cv
::
Rect
>&
objects
,
const
double
factor
=
1.05
,
const
int
step
=
4
,
const
int
rejectfactor
=
1
)
v
oid
cv
::
SoftCascade
::
detectMultiScale
(
const
Mat
&
image
,
const
std
::
vector
<
cv
::
Rect
>&
rois
,
std
::
vector
<
cv
::
Rect
>&
objects
,
const
double
factor
,
const
int
step
,
const
int
rejectfactor
)
{}
v
irtual
void
SoftCascade
::
detectForOctave
(
const
int
octave
)
v
oid
cv
::
SoftCascade
::
detectForOctave
(
const
int
octave
)
{}
\ 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