From db829060674090621cac4d526e21076a0f771e73 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Fri, 9 Jul 2010 09:09:20 +0000 Subject: [PATCH] fix build with GCC 3.3 on Ubuntu 8.04 --- .../include/opencv2/features2d/features2d.hpp | 9 +- modules/imgproc/src/moments.cpp | 2 +- samples/cpp/calibration.cpp | 3 +- tests/cv/src/areprojectImageTo3D.cpp | 2 +- tests/cxcore/src/areduce.cpp | 91 ++++++++++--------- 5 files changed, 57 insertions(+), 50 deletions(-) diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 9e66bd7c8..0675bcbb9 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -1560,6 +1560,7 @@ struct DMatch class CV_EXPORTS DescriptorMatcher { public: + virtual ~DescriptorMatcher() {} /* * Add descriptors to the training set * descriptors Descriptors to add to the training set @@ -1806,7 +1807,7 @@ void BruteForceMatcher::matchImpl( const Mat& descriptors_1, const Mat for( int i = 0; i < descriptors_1.rows; i++ ) { - const ValueType* d1 = descriptors_1.ptr(i); + const ValueType* d1 = (const ValueType*)(descriptors_1.data + descriptors_1.step*i); int matchIndex = -1; DistanceType matchDistance = std::numeric_limits::max(); @@ -1814,7 +1815,7 @@ void BruteForceMatcher::matchImpl( const Mat& descriptors_1, const Mat { if( possibleMatch(mask, i, j) ) { - const ValueType* d2 = descriptors_2.ptr(j); + const ValueType* d2 = (const ValueType*)(descriptors_2.data + descriptors_2.step*j); DistanceType curDistance = distance(d1, d2, dimension); if( curDistance < matchDistance ) { @@ -1854,13 +1855,13 @@ void BruteForceMatcher::matchImpl( const Mat& descriptors_1, const Mat for( int i = 0; i < descriptors_1.rows; i++ ) { - const ValueType* d1 = descriptors_1.ptr(i); + const ValueType* d1 = (const ValueType*)(descriptors_1.data + descriptors_1.step*i); for( int j = 0; j < descriptors_2.rows; j++ ) { if( possibleMatch(mask, i, j) ) { - const ValueType* d2 = descriptors_2.ptr(j); + const ValueType* d2 = (const ValueType*)(descriptors_2.data + descriptors_2.step*j); DistanceType curDistance = distance(d1, d2, dimension); if( curDistance < threshold ) { diff --git a/modules/imgproc/src/moments.cpp b/modules/imgproc/src/moments.cpp index 36aa957a0..fd0125cbc 100644 --- a/modules/imgproc/src/moments.cpp +++ b/modules/imgproc/src/moments.cpp @@ -205,7 +205,7 @@ static void momentsInTile( const cv::Mat& img, double* moments ) for( y = 0; y < size.height; y++ ) { - const T* ptr = img.ptr(y); + const T* ptr = (const T*)(img.data + y*img.step); WT x0 = 0, x1 = 0, x2 = 0; MT x3 = 0; diff --git a/samples/cpp/calibration.cpp b/samples/cpp/calibration.cpp index e21b2ac5b..47ab1e41a 100644 --- a/samples/cpp/calibration.cpp +++ b/samples/cpp/calibration.cpp @@ -171,7 +171,8 @@ void saveCameraParams( const string& filename, for( size_t i = 0; i < imagePoints.size(); i++ ) { Mat r = imagePtMat.row(i).reshape(2, imagePtMat.cols); - Mat(imagePoints[i]).copyTo(r); + Mat imgpti(imagePoints[i]); + imgpti.copyTo(r); } fs << "image_points" << imagePtMat; } diff --git a/tests/cv/src/areprojectImageTo3D.cpp b/tests/cv/src/areprojectImageTo3D.cpp index 41be12417..34ef31948 100644 --- a/tests/cv/src/areprojectImageTo3D.cpp +++ b/tests/cv/src/areprojectImageTo3D.cpp @@ -145,7 +145,7 @@ protected: Mat_ res = Q * Mat_(4, 1, from); res /= res(3, 0); - out3d_t pixel_exp = *res.ptr(); + out3d_t pixel_exp = *(Vec3d*)res.data; out3d_t pixel_out = _3dImg(y, x); const int largeZValue = 10000; /* see documentation */ diff --git a/tests/cxcore/src/areduce.cpp b/tests/cxcore/src/areduce.cpp index 9795689e1..c29ec50f2 100644 --- a/tests/cxcore/src/areduce.cpp +++ b/tests/cxcore/src/areduce.cpp @@ -75,6 +75,11 @@ void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim sum.setTo(Scalar(0)); max.setTo(Scalar(-DBL_MAX)); min.setTo(Scalar(DBL_MAX)); + + const Mat_& src_ = src; + Mat_& sum_ = (Mat_&)sum; + Mat_& min_ = (Mat_&)min; + Mat_& max_ = (Mat_&)max; if( dim == 0 ) { @@ -82,9 +87,9 @@ void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim { for( int ci = 0; ci < src.cols; ci++ ) { - sum.at(0, ci) += src.at(ri, ci); - max.at(0, ci) = std::max( max.at(0, ci), (double)src.at(ri, ci) ); - min.at(0, ci) = std::min( min.at(0, ci), (double)src.at(ri, ci) ); + sum_(0, ci) += src_(ri, ci); + max_(0, ci) = std::max( max_(0, ci), (double)src_(ri, ci) ); + min_(0, ci) = std::min( min_(0, ci), (double)src_(ri, ci) ); } } } @@ -94,9 +99,9 @@ void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim { for( int ri = 0; ri < src.rows; ri++ ) { - sum.at(ri, 0) += src.at(ri, ci); - max.at(ri, 0) = std::max( max.at(ri, 0), (double)src.at(ri, ci) ); - min.at(ri, 0) = std::min( min.at(ri, 0), (double)src.at(ri, ci) ); + sum_(ri, 0) += src_(ri, ci); + max_(ri, 0) = std::max( max_(ri, 0), (double)src_(ri, ci) ); + min_(ri, 0) = std::min( min_(ri, 0), (double)src_(ri, ci) ); } } } @@ -119,37 +124,37 @@ int CV_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat& { int srcType = src.type(); bool support = false; - if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG ) - { - if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) ) - support = true; - if( srcType == CV_16U && (dstType == CV_32F || dstType == CV_64F) ) - support = true; - if( srcType == CV_16S && (dstType == CV_32F || dstType == CV_64F) ) - support = true; - if( srcType == CV_32F && (dstType == CV_32F || dstType == CV_64F) ) - support = true; - if( srcType == CV_64F && dstType == CV_64F) - support = true; - } - else if( opType == CV_REDUCE_MAX ) - { - if( srcType == CV_8U && dstType == CV_8U ) - support = true; - if( srcType == CV_32F && dstType == CV_32F ) - support = true; - if( srcType == CV_64F && dstType == CV_64F ) - support = true; - } - else if( opType == CV_REDUCE_MIN ) - { - if( srcType == CV_8U && dstType == CV_8U) - support = true; - if( srcType == CV_32F && dstType == CV_32F) - support = true; - if( srcType == CV_64F && dstType == CV_64F) - support = true; - } + if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG ) + { + if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) ) + support = true; + if( srcType == CV_16U && (dstType == CV_32F || dstType == CV_64F) ) + support = true; + if( srcType == CV_16S && (dstType == CV_32F || dstType == CV_64F) ) + support = true; + if( srcType == CV_32F && (dstType == CV_32F || dstType == CV_64F) ) + support = true; + if( srcType == CV_64F && dstType == CV_64F) + support = true; + } + else if( opType == CV_REDUCE_MAX ) + { + if( srcType == CV_8U && dstType == CV_8U ) + support = true; + if( srcType == CV_32F && dstType == CV_32F ) + support = true; + if( srcType == CV_64F && dstType == CV_64F ) + support = true; + } + else if( opType == CV_REDUCE_MIN ) + { + if( srcType == CV_8U && dstType == CV_8U) + support = true; + if( srcType == CV_32F && dstType == CV_32F) + support = true; + if( srcType == CV_64F && dstType == CV_64F) + support = true; + } if( !support ) return CvTS::OK; @@ -158,7 +163,7 @@ int CV_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat& reduce( src, _dst, dim, opType, dstType ); _dst.convertTo( dst, CV_64FC1 ); if( norm( opRes, dst, NORM_INF ) > eps ) - { + { char msg[100]; const char* opTypeStr = opType == CV_REDUCE_SUM ? "CV_REDUCE_SUM" : opType == CV_REDUCE_AVG ? "CV_REDUCE_AVG" : @@ -168,11 +173,11 @@ int CV_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat& getMatTypeStr( src.type(), srcTypeStr ); getMatTypeStr( dstType, dstTypeStr ); const char* dimStr = dim == 0 ? "ROWS" : "COLS"; - - sprintf( msg, "bad accuracy with srcType = %s, dstType = %s, opType = %s, dim = %s", - srcTypeStr.c_str(), dstTypeStr.c_str(), opTypeStr, dimStr ); - ts->printf( CvTS::LOG, msg ); - return CvTS::FAIL_BAD_ACCURACY; + + sprintf( msg, "bad accuracy with srcType = %s, dstType = %s, opType = %s, dim = %s", + srcTypeStr.c_str(), dstTypeStr.c_str(), opTypeStr, dimStr ); + ts->printf( CvTS::LOG, msg ); + return CvTS::FAIL_BAD_ACCURACY; } return CvTS::OK; }