Fixed FernDescriptorMatch and undid change of FernClassifier

This commit is contained in:
Ilya Lysenkov 2010-06-08 13:21:47 +00:00
parent ab8861fa10
commit 892cc8aab7
2 changed files with 5 additions and 5 deletions

View File

@ -549,15 +549,15 @@ void FernDescriptorMatch::trainFernClassifier()
assert( params.filename.empty() ); assert( params.filename.empty() );
vector<Point2f> points; vector<Point2f> points;
vector<Ptr<Mat> > refimgs( collection.images.size() ); vector<Ptr<Mat> > refimgs;
vector<int> labels; vector<int> labels;
for( size_t imageIdx = 0; imageIdx < collection.images.size(); imageIdx++ ) for( size_t imageIdx = 0; imageIdx < collection.images.size(); imageIdx++ )
{ {
refimgs[imageIdx] = new Mat (collection.images[imageIdx]);
for( size_t pointIdx = 0; pointIdx < collection.points[imageIdx].size(); pointIdx++ ) for( size_t pointIdx = 0; pointIdx < collection.points[imageIdx].size(); pointIdx++ )
{ {
refimgs.push_back(new Mat (collection.images[imageIdx]));
points.push_back(collection.points[imageIdx][pointIdx].pt); points.push_back(collection.points[imageIdx][pointIdx].pt);
labels.push_back(imageIdx); labels.push_back(pointIdx);
} }
} }
@ -572,7 +572,7 @@ void FernDescriptorMatch::calcBestProbAndMatchIdx( const Mat& image, const Point
{ {
(*classifier)( image, pt, signature); (*classifier)( image, pt, signature);
bestProb = 0; bestProb = -FLT_MAX;
bestMatchIdx = -1; bestMatchIdx = -1;
for( size_t ci = 0; ci < (size_t)classifier->getClassCount(); ci++ ) for( size_t ci = 0; ci < (size_t)classifier->getClassCount(); ci++ )
{ {

View File

@ -853,7 +853,7 @@ void FernClassifier::train(const vector<Point2f>& points,
for( i = 0; i < nsamples; i++ ) for( i = 0; i < nsamples; i++ )
{ {
Point2f pt = points[i]; Point2f pt = points[i];
const Mat& src = labels.empty() ? *refimgs[i] : *refimgs[labels[i]]; const Mat& src = *refimgs[i];
int classId = labels.empty() ? i : labels[i]; int classId = labels.empty() ? i : labels[i];
if( verbose && (i+1)*progressBarSize/nsamples != i*progressBarSize/nsamples ) if( verbose && (i+1)*progressBarSize/nsamples != i*progressBarSize/nsamples )
putchar('.'); putchar('.');