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
4356d345
Commit
4356d345
authored
Dec 14, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
write features to soft cascade xml
parent
1f010529
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
11 deletions
+38
-11
octave.hpp
apps/sft/include/sft/octave.hpp
+8
-4
octave.cpp
apps/sft/octave.cpp
+28
-5
sft.cpp
apps/sft/sft.cpp
+2
-2
No files found.
apps/sft/include/sft/octave.hpp
View file @
4356d345
...
@@ -95,9 +95,11 @@ private:
...
@@ -95,9 +95,11 @@ private:
cv
::
Rect
bb
;
cv
::
Rect
bb
;
int
channel
;
int
channel
;
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
ICF
&
m
);
friend
void
write
(
cv
::
FileStorage
&
fs
,
const
string
&
,
const
ICF
&
f
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
ICF
&
f
);
};
};
void
write
(
cv
::
FileStorage
&
fs
,
const
string
&
,
const
ICF
&
f
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
ICF
&
m
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
ICF
&
m
);
class
FeaturePool
class
FeaturePool
...
@@ -107,6 +109,7 @@ public:
...
@@ -107,6 +109,7 @@ public:
int
size
()
const
{
return
(
int
)
pool
.
size
();
}
int
size
()
const
{
return
(
int
)
pool
.
size
();
}
float
apply
(
int
fi
,
int
si
,
const
Mat
&
integrals
)
const
;
float
apply
(
int
fi
,
int
si
,
const
Mat
&
integrals
)
const
;
void
write
(
cv
::
FileStorage
&
fs
,
int
index
)
const
;
private
:
private
:
void
fill
(
int
desired
);
void
fill
(
int
desired
);
...
@@ -140,11 +143,11 @@ public:
...
@@ -140,11 +143,11 @@ public:
virtual
~
Octave
();
virtual
~
Octave
();
virtual
bool
train
(
const
Dataset
&
dataset
,
const
FeaturePool
&
pool
,
int
weaks
,
int
treeDepth
);
virtual
bool
train
(
const
Dataset
&
dataset
,
const
FeaturePool
&
pool
,
int
weaks
,
int
treeDepth
);
virtual
void
write
(
CvFileStorage
*
fs
,
string
name
)
const
;
virtual
float
predict
(
const
Mat
&
_sample
,
Mat
&
_votes
,
bool
raw_mode
,
bool
return_sum
)
const
;
virtual
float
predict
(
const
Mat
&
_sample
,
Mat
&
_votes
,
bool
raw_mode
,
bool
return_sum
)
const
;
virtual
void
setRejectThresholds
(
cv
::
Mat
&
thresholds
);
virtual
void
setRejectThresholds
(
cv
::
Mat
&
thresholds
);
virtual
void
write
(
CvFileStorage
*
fs
,
string
name
)
const
;
virtual
void
write
(
cv
::
FileStorage
&
fs
,
const
Mat
&
thresholds
=
Mat
())
const
;
virtual
void
write
(
cv
::
FileStorage
&
fs
,
const
FeaturePool
&
pool
,
const
Mat
&
thresholds
=
Mat
())
const
;
int
logScale
;
int
logScale
;
...
@@ -157,8 +160,9 @@ protected:
...
@@ -157,8 +160,9 @@ protected:
float
predict
(
const
Mat
&
_sample
,
const
cv
::
Range
range
)
const
;
float
predict
(
const
Mat
&
_sample
,
const
cv
::
Range
range
)
const
;
private
:
private
:
void
traverse
(
const
CvBoostTree
*
tree
,
cv
::
FileStorage
&
fs
,
const
float
*
th
=
0
)
const
;
void
traverse
(
const
CvBoostTree
*
tree
,
cv
::
FileStorage
&
fs
,
int
&
nfeatures
,
int
*
used
,
const
float
*
th
=
0
)
const
;
virtual
void
initial_weights
(
double
(
&
p
)[
2
]);
virtual
void
initial_weights
(
double
(
&
p
)[
2
]);
cv
::
Rect
boundingBox
;
cv
::
Rect
boundingBox
;
int
npositives
;
int
npositives
;
...
...
apps/sft/octave.cpp
View file @
4356d345
...
@@ -300,7 +300,7 @@ template <typename T> int sgn(T val) {
...
@@ -300,7 +300,7 @@ template <typename T> int sgn(T val) {
return
(
T
(
0
)
<
val
)
-
(
val
<
T
(
0
));
return
(
T
(
0
)
<
val
)
-
(
val
<
T
(
0
));
}
}
void
sft
::
Octave
::
traverse
(
const
CvBoostTree
*
tree
,
cv
::
FileStorage
&
fs
,
const
float
*
th
)
const
void
sft
::
Octave
::
traverse
(
const
CvBoostTree
*
tree
,
cv
::
FileStorage
&
fs
,
int
&
nfeatures
,
int
*
used
,
const
float
*
th
)
const
{
{
std
::
queue
<
const
CvDTreeNode
*>
nodes
;
std
::
queue
<
const
CvDTreeNode
*>
nodes
;
nodes
.
push
(
tree
->
get_root
());
nodes
.
push
(
tree
->
get_root
());
...
@@ -336,8 +336,10 @@ void sft::Octave::traverse(const CvBoostTree* tree, cv::FileStorage& fs, const f
...
@@ -336,8 +336,10 @@ void sft::Octave::traverse(const CvBoostTree* tree, cv::FileStorage& fs, const f
nodes
.
push
(
tempNode
->
right
);
nodes
.
push
(
tempNode
->
right
);
fs
<<
internalNodeIdx
++
;
fs
<<
internalNodeIdx
++
;
}
}
int
fidx
=
tempNode
->
split
->
var_idx
;
int
fidx
=
tempNode
->
split
->
var_idx
;
fs
<<
fidx
;
fs
<<
nfeatures
;
used
[
nfeatures
++
]
=
fidx
;
fs
<<
tempNode
->
split
->
ord
.
c
;
fs
<<
tempNode
->
split
->
ord
.
c
;
...
@@ -353,8 +355,11 @@ void sft::Octave::traverse(const CvBoostTree* tree, cv::FileStorage& fs, const f
...
@@ -353,8 +355,11 @@ void sft::Octave::traverse(const CvBoostTree* tree, cv::FileStorage& fs, const f
fs
<<
"}"
;
fs
<<
"}"
;
}
}
void
sft
::
Octave
::
write
(
cv
::
FileStorage
&
fso
,
const
Mat
&
thresholds
)
const
void
sft
::
Octave
::
write
(
cv
::
FileStorage
&
fso
,
const
FeaturePool
&
pool
,
const
Mat
&
thresholds
)
const
{
{
cv
::
Mat
used
(
1
,
weak
->
total
*
(
pow
(
2
,
params
.
max_depth
)
-
1
),
CV_32SC1
);
int
*
usedPtr
=
used
.
ptr
<
int
>
(
0
);
int
nfeatures
=
0
;
fso
<<
"{"
fso
<<
"{"
<<
"scale"
<<
logScale
<<
"scale"
<<
logScale
<<
"weaks"
<<
weak
->
total
<<
"weaks"
<<
weak
->
total
...
@@ -369,12 +374,19 @@ void sft::Octave::write( cv::FileStorage &fso, const Mat& thresholds) const
...
@@ -369,12 +374,19 @@ void sft::Octave::write( cv::FileStorage &fso, const Mat& thresholds) const
CV_READ_SEQ_ELEM
(
tree
,
reader
);
CV_READ_SEQ_ELEM
(
tree
,
reader
);
if
(
!
thresholds
.
empty
())
if
(
!
thresholds
.
empty
())
traverse
(
tree
,
fso
,
thresholds
.
ptr
<
float
>
(
0
)
+
i
);
traverse
(
tree
,
fso
,
nfeatures
,
usedPtr
,
thresholds
.
ptr
<
float
>
(
0
)
+
i
);
else
else
traverse
(
tree
,
fso
);
traverse
(
tree
,
fso
,
nfeatures
,
usedPtr
);
}
}
//
//
fso
<<
"]"
;
// features
fso
<<
"features"
<<
"["
;
for
(
int
i
=
0
;
i
<
nfeatures
;
++
i
)
// fso << usedPtr[i];
pool
.
write
(
fso
,
usedPtr
[
i
]);
fso
<<
"]"
fso
<<
"]"
<<
"}"
;
<<
"}"
;
}
}
...
@@ -483,6 +495,17 @@ float sft::FeaturePool::apply(int fi, int si, const Mat& integrals) const
...
@@ -483,6 +495,17 @@ float sft::FeaturePool::apply(int fi, int si, const Mat& integrals) const
return
pool
[
fi
](
integrals
.
row
(
si
),
model
);
return
pool
[
fi
](
integrals
.
row
(
si
),
model
);
}
}
void
sft
::
FeaturePool
::
write
(
cv
::
FileStorage
&
fs
,
int
index
)
const
{
CV_Assert
((
index
>
0
)
&&
(
index
<
(
int
)
pool
.
size
()));
fs
<<
pool
[
index
];
}
void
sft
::
write
(
cv
::
FileStorage
&
fs
,
const
string
&
,
const
ICF
&
f
)
{
fs
<<
"{"
<<
"channel"
<<
f
.
channel
<<
"rect"
<<
f
.
bb
<<
"}"
;
}
void
sft
::
FeaturePool
::
fill
(
int
desired
)
void
sft
::
FeaturePool
::
fill
(
int
desired
)
{
{
...
...
apps/sft/sft.cpp
View file @
4356d345
...
@@ -162,8 +162,8 @@ int main(int argc, char** argv)
...
@@ -162,8 +162,8 @@ int main(int argc, char** argv)
cv
::
Mat
thresholds
;
cv
::
Mat
thresholds
;
boost
.
setRejectThresholds
(
thresholds
);
boost
.
setRejectThresholds
(
thresholds
);
boost
.
write
(
fso
,
thresholds
);
boost
.
write
(
fso
,
pool
,
thresholds
);
boost
.
write
(
fsr
);
boost
.
write
(
fsr
,
pool
);
// std::cout << "thresholds " << thresholds << std::endl;
// std::cout << "thresholds " << thresholds << std::endl;
cv
::
FileStorage
tfs
((
"thresholds."
+
cfg
.
resPath
(
it
)).
c_str
(),
cv
::
FileStorage
::
WRITE
);
cv
::
FileStorage
tfs
((
"thresholds."
+
cfg
.
resPath
(
it
)).
c_str
(),
cv
::
FileStorage
::
WRITE
);
...
...
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