diff --git a/modules/features2d/test/test_descriptors_regression.cpp b/modules/features2d/test/test_descriptors_regression.cpp index 5ebf508d8..717cae58d 100644 --- a/modules/features2d/test/test_descriptors_regression.cpp +++ b/modules/features2d/test/test_descriptors_regression.cpp @@ -60,7 +60,7 @@ static void writeMatInBin( const Mat& mat, const string& filename ) fwrite( (void*)&mat.rows, sizeof(int), 1, f ); fwrite( (void*)&mat.cols, sizeof(int), 1, f ); fwrite( (void*)&type, sizeof(int), 1, f ); - int dataSize = (int)(mat.step * mat.rows * mat.channels()); + int dataSize = (int)(mat.step * mat.rows); fwrite( (void*)&dataSize, sizeof(int), 1, f ); fwrite( (void*)mat.ptr(), 1, dataSize, f ); fclose(f); @@ -82,13 +82,14 @@ static Mat readMatFromBin( const string& filename ) int step = dataSize / rows / CV_ELEM_SIZE(type); CV_Assert(step >= cols); - Mat m = Mat(rows, step, type).colRange(0, cols); + Mat returnMat = Mat(rows, step, type).colRange(0, cols); - size_t elements_read = fread( m.ptr(), 1, dataSize, f ); + size_t elements_read = fread( returnMat.ptr(), 1, dataSize, f ); CV_Assert(elements_read == (size_t)(dataSize)); + fclose(f); - return m; + return returnMat; } return Mat(); }