diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 88aa10566..a0ff4cc05 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -1505,7 +1505,7 @@ void CalonderDescriptorExtractor::compute( const cv::Mat& image, int offset = patchSize / 2; for (size_t i = 0; i < keypoints.size(); ++i) { cv::Point2f pt = keypoints[i].pt; - IplImage ipl = image( Rect(pt.x - offset, pt.y - offset, patchSize, patchSize) ); + IplImage ipl = image( Rect((int)(pt.x - offset), (int)(pt.y - offset), patchSize, patchSize) ); classifier_.getSignature( &ipl, descriptors.ptr(i)); } } @@ -1515,7 +1515,7 @@ void CalonderDescriptorExtractor::read( const FileNode& ) {} template -void CalonderDescriptorExtractor::write( FileStorage&s ) const +void CalonderDescriptorExtractor::write( FileStorage& ) const {} CV_EXPORTS Ptr createDescriptorExtractor( const string& descriptorExtractorType ); diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index b89d68bc0..a8bf2f717 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -79,11 +79,11 @@ Mat windowedMatchingMask( const vector& keypoints1, const vector >::matchImpl( const Mat& query, const Mat& mask { match.indexQuery = i; double queryNorm = norm( query.row(i) ); - match.distance = sqrt( minVal + queryNorm*queryNorm ); + match.distance = (float)sqrt( minVal + queryNorm*queryNorm ); matches.push_back( match ); } } diff --git a/modules/features2d/src/evaluation.cpp b/modules/features2d/src/evaluation.cpp index d30ab6140..992c99e02 100644 --- a/modules/features2d/src/evaluation.cpp +++ b/modules/features2d/src/evaluation.cpp @@ -46,18 +46,18 @@ using namespace cv; using namespace std; -inline Point2f applyHomography( const Mat_& H, const Point2f& pt ) +static inline Point2f applyHomography( const Mat_& H, const Point2f& pt ) { double z = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2); if( z ) { double w = 1./z; - return Point2f( (H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w, (H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w ); + return Point2f( (float)((H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w), (float)((H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w) ); } - return Point2f( numeric_limits::max(), numeric_limits::max() ); + return Point2f( numeric_limits::max(), numeric_limits::max() ); } -inline void linearizeHomographyAt( const Mat_& H, const Point2f& pt, Mat_& A ) +static inline void linearizeHomographyAt( const Mat_& H, const Point2f& pt, Mat_& A ) { A.create(2,2); double p1 = H(0,0)*pt.x + H(0,1)*pt.y + H(0,2), @@ -110,12 +110,12 @@ EllipticKeyPoint::EllipticKeyPoint( const Point2f& _center, const Scalar& _ellip Mat_ M = getSecondMomentsMatrix(_ellipse), eval; eigen( M, eval ); assert( eval.rows == 2 && eval.cols == 1 ); - axes.width = 1.f / sqrt(eval(0,0)); - axes.height = 1.f / sqrt(eval(1,0)); + axes.width = 1.f / (float)sqrt(eval(0,0)); + axes.height = 1.f / (float)sqrt(eval(1,0)); - float ac_b2 = ellipse[0]*ellipse[2] - ellipse[1]*ellipse[1]; - boundingBox.width = sqrt(ellipse[2]/ac_b2); - boundingBox.height = sqrt(ellipse[0]/ac_b2); + double ac_b2 = ellipse[0]*ellipse[2] - ellipse[1]*ellipse[1]; + boundingBox.width = (float)sqrt(ellipse[2]/ac_b2); + boundingBox.height = (float)sqrt(ellipse[0]/ac_b2); } Mat_ EllipticKeyPoint::getSecondMomentsMatrix( const Scalar& _ellipse ) @@ -223,7 +223,7 @@ static void overlap( const vector& keypoints1, const vector& keypoints1, const vector& keypoints1, const vector fde(dir + "/classifier.rtc"); Mat fdescriptors; - double t = getTickCount(); + double t = (double)getTickCount(); fde.compute(img, keypoints, fdescriptors); t = getTickCount() - t; ts->printf(CvTS::LOG, "\nAverage time of computiting float descriptor = %g ms\n", t/((double)cvGetTickFrequency()*1000.)/fdescriptors.rows ); @@ -143,7 +143,7 @@ void CV_CalonderTest::run(int) CalonderDescriptorExtractor cde(dir + "/classifier.rtc"); Mat cdescriptors; - t = getTickCount(); + t = (double)getTickCount(); cde.compute(img, keypoints, cdescriptors); t = getTickCount() - t; ts->printf(CvTS::LOG, "Average time of computiting uchar descriptor = %g ms\n", t/((double)cvGetTickFrequency()*1000.)/cdescriptors.rows ); diff --git a/tests/cv/src/adetectordescriptor_evaluation.cpp b/tests/cv/src/adetectordescriptor_evaluation.cpp index f00388db0..cb7d4d99b 100644 --- a/tests/cv/src/adetectordescriptor_evaluation.cpp +++ b/tests/cv/src/adetectordescriptor_evaluation.cpp @@ -52,8 +52,35 @@ using namespace cv; * Functions to evaluate affine covariant detectors and descriptors. * \****************************************************************************************/ -Point2f applyHomography( const Mat_& H, const Point2f& pt ); -void linearizeHomographyAt( const Mat_& H, const Point2f& pt, Mat_& A ); +static inline Point2f applyHomography( const Mat_& H, const Point2f& pt ) +{ + double z = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2); + if( z ) + { + double w = 1./z; + return Point2f( (H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w, (H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w ); + } + return Point2f( numeric_limits::max(), numeric_limits::max() ); +} + +static inline void linearizeHomographyAt( const Mat_& H, const Point2f& pt, Mat_& A ) +{ + A.create(2,2); + double p1 = H(0,0)*pt.x + H(0,1)*pt.y + H(0,2), + p2 = H(1,0)*pt.x + H(1,1)*pt.y + H(1,2), + p3 = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2), + p3_2 = p3*p3; + if( p3 ) + { + A(0,0) = H(0,0)/p3 - p1*H(2,0)/p3_2; // fxdx + A(0,1) = H(0,1)/p3 - p1*H(2,1)/p3_2; // fxdy + + A(1,0) = H(1,0)/p3 - p2*H(2,0)/p3_2; // fydx + A(1,1) = H(1,1)/p3 - p2*H(2,1)/p3_2; // fydx + } + else + A.setTo(Scalar::all(numeric_limits::max())); +} void calcKeyPointProjections( const vector& src, const Mat_& H, vector& dst ) { @@ -1066,7 +1093,7 @@ int DescriptorQualityTest::processResults( int datasetIdx, int caseIdx ) Quality valid = validQuality[datasetIdx][caseIdx], calc = calcQuality[datasetIdx][caseIdx]; bool isBadAccuracy; - const float rltvEps = 0.001; + const float rltvEps = 0.001f; ts->printf(CvTS::LOG, "%s: calc=%f, valid=%f", RECALL.c_str(), calc.recall, valid.recall ); isBadAccuracy = valid.recall - calc.recall > rltvEps; testLog( ts, isBadAccuracy );