Fix memory corruption in batchDistance perf tests

This commit is contained in:
Andrey Kamaev 2012-12-22 21:01:57 +04:00
parent ffdbddd6b1
commit b870b246e1

View File

@ -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<float>(0, elem) += diff;
trainDescriptor.col(elem) += diff;
}
}
}