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
69304611
Commit
69304611
authored
Dec 11, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commented debug out
parent
2e4b8d07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
17 deletions
+21
-17
octave.cpp
apps/sft/octave.cpp
+14
-14
sft.cpp
apps/sft/sft.cpp
+7
-3
No files found.
apps/sft/octave.cpp
View file @
69304611
...
@@ -84,11 +84,11 @@ bool sft::Octave::train( const cv::Mat& _trainData, const cv::Mat& _responses, c
...
@@ -84,11 +84,11 @@ bool sft::Octave::train( const cv::Mat& _trainData, const cv::Mat& _responses, c
const
cv
::
Mat
&
sampleIdx
,
const
cv
::
Mat
&
varType
,
const
cv
::
Mat
&
missingDataMask
)
const
cv
::
Mat
&
sampleIdx
,
const
cv
::
Mat
&
varType
,
const
cv
::
Mat
&
missingDataMask
)
{
{
std
::
cout
<<
"WARNING: sampleIdx "
<<
sampleIdx
<<
std
::
endl
;
//
std::cout << "WARNING: sampleIdx " << sampleIdx << std::endl;
std
::
cout
<<
"WARNING: trainData "
<<
_trainData
<<
std
::
endl
;
//
std::cout << "WARNING: trainData " << _trainData << std::endl;
std
::
cout
<<
"WARNING: _responses "
<<
_responses
<<
std
::
endl
;
//
std::cout << "WARNING: _responses " << _responses << std::endl;
std
::
cout
<<
"WARNING: varIdx"
<<
varIdx
<<
std
::
endl
;
//
std::cout << "WARNING: varIdx" << varIdx << std::endl;
std
::
cout
<<
"WARNING: varType"
<<
varType
<<
std
::
endl
;
//
std::cout << "WARNING: varType" << varType << std::endl;
bool
update
=
false
;
bool
update
=
false
;
return
cv
::
Boost
::
train
(
_trainData
,
CV_COL_SAMPLE
,
_responses
,
varIdx
,
sampleIdx
,
varType
,
missingDataMask
,
params
,
return
cv
::
Boost
::
train
(
_trainData
,
CV_COL_SAMPLE
,
_responses
,
varIdx
,
sampleIdx
,
varType
,
missingDataMask
,
params
,
...
@@ -117,9 +117,9 @@ void sft::Octave::setRejectThresholds(cv::Mat& thresholds)
...
@@ -117,9 +117,9 @@ void sft::Octave::setRejectThresholds(cv::Mat& thresholds)
mptr
[
si
]
=
cv
::
saturate_cast
<
uchar
>
((
uint
)(
responses
.
ptr
<
float
>
(
si
)[
0
]
==
1.
f
&&
decision
==
1.
f
));
mptr
[
si
]
=
cv
::
saturate_cast
<
uchar
>
((
uint
)(
responses
.
ptr
<
float
>
(
si
)[
0
]
==
1.
f
&&
decision
==
1.
f
));
}
}
std
::
cout
<<
"WARNING: responses "
<<
responses
<<
std
::
endl
;
//
std::cout << "WARNING: responses " << responses << std::endl;
std
::
cout
<<
"WARNING: desisions "
<<
desisions
<<
std
::
endl
;
//
std::cout << "WARNING: desisions " << desisions << std::endl;
std
::
cout
<<
"WARNING: ppmask "
<<
ppmask
<<
std
::
endl
;
//
std::cout << "WARNING: ppmask " << ppmask << std::endl;
int
weaks
=
weak
->
total
;
int
weaks
=
weak
->
total
;
thresholds
.
create
(
1
,
weaks
,
CV_64FC1
);
thresholds
.
create
(
1
,
weaks
,
CV_64FC1
);
...
@@ -142,7 +142,7 @@ void sft::Octave::setRejectThresholds(cv::Mat& thresholds)
...
@@ -142,7 +142,7 @@ void sft::Octave::setRejectThresholds(cv::Mat& thresholds)
double
mintrace
=
0.
;
double
mintrace
=
0.
;
cv
::
minMaxLoc
(
traces
.
row
(
w
),
&
mintrace
);
cv
::
minMaxLoc
(
traces
.
row
(
w
),
&
mintrace
);
thptr
[
w
]
=
mintrace
;
thptr
[
w
]
=
mintrace
;
std
::
cout
<<
"mintrace "
<<
mintrace
<<
std
::
endl
<<
traces
.
colRange
(
0
,
npositives
)
<<
std
::
endl
;
//
std::cout << "mintrace " << mintrace << std::endl << traces.colRange(0, npositives) << std::endl;
}
}
}
}
...
@@ -223,7 +223,7 @@ void sft::Octave::processPositives(const Dataset& dataset, const FeaturePool& po
...
@@ -223,7 +223,7 @@ void sft::Octave::processPositives(const Dataset& dataset, const FeaturePool& po
{
{
const
string
&
curr
=
*
it
;
const
string
&
curr
=
*
it
;
dprintf
(
"Process candidate positive image %s
\n
"
,
curr
.
c_str
());
//
dprintf("Process candidate positive image %s\n", curr.c_str());
cv
::
Mat
sample
=
cv
::
imread
(
curr
);
cv
::
Mat
sample
=
cv
::
imread
(
curr
);
...
@@ -262,8 +262,8 @@ void sft::Octave::generateNegatives(const Dataset& dataset)
...
@@ -262,8 +262,8 @@ void sft::Octave::generateNegatives(const Dataset& dataset)
{
{
int
curr
=
iRand
(
idxEng
);
int
curr
=
iRand
(
idxEng
);
dprintf
(
"View %d-th sample
\n
"
,
curr
);
//
dprintf("View %d-th sample\n", curr);
dprintf
(
"Process %s
\n
"
,
dataset
.
neg
[
curr
].
c_str
());
//
dprintf("Process %s\n", dataset.neg[curr].c_str());
Mat
frame
=
cv
::
imread
(
dataset
.
neg
[
curr
]);
Mat
frame
=
cv
::
imread
(
dataset
.
neg
[
curr
]);
...
@@ -349,12 +349,12 @@ bool sft::Octave::train(const Dataset& dataset, const FeaturePool& pool, int wea
...
@@ -349,12 +349,12 @@ bool sft::Octave::train(const Dataset& dataset, const FeaturePool& pool, int wea
cv
::
Mat
a
(
1
,
nfeatures
,
CV_32FC1
);
cv
::
Mat
a
(
1
,
nfeatures
,
CV_32FC1
);
cv
::
Mat
votes
(
1
,
cvSliceLength
(
CV_WHOLE_SEQ
,
weak
),
CV_32FC1
,
cv
::
Scalar
::
all
(
0
));
cv
::
Mat
votes
(
1
,
cvSliceLength
(
CV_WHOLE_SEQ
,
weak
),
CV_32FC1
,
cv
::
Scalar
::
all
(
0
));
std
::
cout
<<
a
.
cols
<<
" "
<<
a
.
rows
<<
" !!!!!!!!!!! "
<<
data
->
var_all
<<
std
::
endl
;
//
std::cout << a.cols << " " << a.rows << " !!!!!!!!!!! " << data->var_all << std::endl;
for
(
int
si
=
0
;
si
<
nsamples
;
++
si
)
for
(
int
si
=
0
;
si
<
nsamples
;
++
si
)
{
{
// trainData.col(si).copyTo(a.reshape(0,trainData.rows));
// trainData.col(si).copyTo(a.reshape(0,trainData.rows));
float
desision
=
predict
(
trainData
.
col
(
si
),
votes
,
false
,
true
);
float
desision
=
predict
(
trainData
.
col
(
si
),
votes
,
false
,
true
);
std
::
cout
<<
"desision "
<<
desision
<<
" class "
<<
responses
.
at
<
float
>
(
si
,
0
)
<<
votes
<<
std
::
endl
;
//
std::cout << "desision " << desision << " class " << responses.at<float>(si, 0) << votes <<std::endl;
}
}
#endif
#endif
return
ok
;
return
ok
;
...
...
apps/sft/sft.cpp
View file @
69304611
...
@@ -129,16 +129,20 @@ int main(int argc, char** argv)
...
@@ -129,16 +129,20 @@ int main(int argc, char** argv)
if
(
boost
.
train
(
dataset
,
pool
,
cfg
.
weaks
,
cfg
.
treeDepth
))
if
(
boost
.
train
(
dataset
,
pool
,
cfg
.
weaks
,
cfg
.
treeDepth
))
{
{
std
::
cout
<<
"Octave "
<<
*
it
<<
" was successfully trained..."
<<
std
::
endl
;
CvFileStorage
*
fout
=
cvOpenFileStorage
(
cfg
.
resPath
(
it
).
c_str
(),
0
,
CV_STORAGE_WRITE
);
CvFileStorage
*
fout
=
cvOpenFileStorage
(
cfg
.
resPath
(
it
).
c_str
(),
0
,
CV_STORAGE_WRITE
);
boost
.
write
(
fout
,
cfg
.
cascadeName
);
boost
.
write
(
fout
,
cfg
.
cascadeName
);
// strong.push_back(octave);
cvReleaseFileStorage
(
&
fout
);
cvReleaseFileStorage
(
&
fout
);
cv
::
Mat
thresholds
;
cv
::
Mat
thresholds
;
boost
.
setRejectThresholds
(
thresholds
);
boost
.
setRejectThresholds
(
thresholds
);
std
::
cout
<<
"thresholds "
<<
thresholds
<<
std
::
endl
;
// std::cout << "thresholds " << thresholds << std::endl;
cv
::
FileStorage
tfs
((
"thresholds."
+
cfg
.
resPath
(
it
)).
c_str
(),
cv
::
FileStorage
::
WRITE
);
tfs
<<
"thresholds"
<<
thresholds
;
std
::
cout
<<
"Octave "
<<
*
it
<<
" was successfully trained..."
<<
std
::
endl
;
}
}
}
}
...
...
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