From b870b246e106bedff4a7e9fd0cd45b9c1f394dd5 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Sat, 22 Dec 2012 21:01:57 +0400 Subject: [PATCH] Fix memory corruption in batchDistance perf tests --- modules/features2d/perf/perf_batchDistance.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/features2d/perf/perf_batchDistance.cpp b/modules/features2d/perf/perf_batchDistance.cpp index 157b59fb4a..75a2aa1f40 100644 --- a/modules/features2d/perf/perf_batchDistance.cpp +++ b/modules/features2d/perf/perf_batchDistance.cpp @@ -150,7 +150,7 @@ void generateData( Mat& query, Mat& train, const int sourceType ) // in ascending order. General boundaries of the perturbation // are (0.f, 1.f). train.create( query.rows*countFactor, query.cols, sourceType ); - float step = 1.f / countFactor; + float step = (sourceType == CV_8U ? 256.f : 1.f) / countFactor; for( int qIdx = 0; qIdx < query.rows; qIdx++ ) { Mat queryDescriptor = query.row(qIdx); @@ -161,7 +161,7 @@ void generateData( Mat& query, Mat& train, const int sourceType ) queryDescriptor.copyTo( trainDescriptor ); int elem = rng(dim); float diff = rng.uniform( step*c, step*(c+1) ); - trainDescriptor.at(0, elem) += diff; + trainDescriptor.col(elem) += diff; } } }