From 15413c8d40e09b0020c4de4b3d77cf09ce5d2204 Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Tue, 8 Jun 2010 06:54:17 +0000 Subject: [PATCH] Fixed bugs in FernDescriptorMatch and FernClassifier --- modules/features2d/src/descriptors.cpp | 2 +- modules/features2d/src/planardetect.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index e570f0e96..dbb7a41c3 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -541,7 +541,7 @@ void FernDescriptorMatch::trainFernClassifier() vector labels; for( size_t imageIdx = 0; imageIdx < collection.images.size(); imageIdx++ ) { - refimgs[imageIdx] = &collection.images[imageIdx]; + refimgs[imageIdx] = new Mat (collection.images[imageIdx]); for( size_t pointIdx = 0; pointIdx < collection.points[imageIdx].size(); pointIdx++ ) { points.push_back(collection.points[imageIdx][pointIdx].pt); diff --git a/modules/features2d/src/planardetect.cpp b/modules/features2d/src/planardetect.cpp index fc062be38..03e9d2398 100644 --- a/modules/features2d/src/planardetect.cpp +++ b/modules/features2d/src/planardetect.cpp @@ -853,7 +853,7 @@ void FernClassifier::train(const vector& points, for( i = 0; i < nsamples; i++ ) { Point2f pt = points[i]; - const Mat& src = *refimgs[i]; + const Mat& src = labels.empty() ? *refimgs[i] : *refimgs[labels[i]]; int classId = labels.empty() ? i : labels[i]; if( verbose && (i+1)*progressBarSize/nsamples != i*progressBarSize/nsamples ) putchar('.');