- add missing tests for ORB
authorVincent Rabaud <no@email>
Fri, 20 May 2011 23:53:22 +0000 (23:53 +0000)
committerVincent Rabaud <no@email>
Fri, 20 May 2011 23:53:22 +0000 (23:53 +0000)
- remove useless code for 2.3

modules/features2d/src/orb.cpp
modules/features2d/test/test_features2d.cpp

index 889c279..3868def 100644 (file)
@@ -195,40 +195,6 @@ void HarrisResponse::operator()(std::vector<cv::KeyPoint>& kpts) const
   }
 }
 
-namespace
-{
-struct RoiPredicate
-{
-  RoiPredicate(const cv::Rect& r) :
-    r(r)
-  {
-  }
-
-  bool operator()(const cv::KeyPoint& keyPt) const
-  {
-    return !r.contains(keyPt.pt);
-  }
-
-  cv::Rect r;
-};
-
-void runByImageBorder(std::vector<cv::KeyPoint>& keypoints, cv::Size imageSize, int borderSize)
-{
-  if (borderSize > 0)
-  {
-    keypoints.erase(
-                    std::remove_if(
-                                   keypoints.begin(),
-                                   keypoints.end(),
-                                   RoiPredicate(
-                                                cv::Rect(
-                                                         cv::Point(borderSize, borderSize),
-                                                         cv::Point(imageSize.width - borderSize,
-                                                                   imageSize.height - borderSize)))), keypoints.end());
-  }
-}
-}
-
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 inline bool keypointResponseGreater(const cv::KeyPoint& lhs, const cv::KeyPoint& rhs)
@@ -669,11 +635,7 @@ void ORB::computeKeyPoints(const std::vector<cv::Mat>& image_pyramid, const std:
     // Remove keypoints very close to the border
     // half_patch_size_ for orientation, 4 for Harris
     unsigned int border_safety = std::max(half_patch_size_, 4);
-#if ((CV_MAJOR_VERSION >= 2) && ((CV_MINOR_VERSION >2) || ((CV_MINOR_VERSION == 2) && (CV_SUBMINOR_VERSION>=9))))
     cv::KeyPointsFilter::runByImageBorder(keypoints, image_pyramid[level].size(), border_safety);
-#else
-    ::runByImageBorder(keypoints, image_pyramid[level].size(), border_safety);
-#endif
 
     // Keep more points than necessary as FAST does not give amazing corners
     if (keypoints.size() > 2 * n_features_per_level_[level])
@@ -843,7 +805,7 @@ void ORB::computeDescriptors(const cv::Mat& image, const cv::Mat& integral_image
   cv::KeyPointsFilter::runByImageBorder(keypoints, image.size(), border_safety);
 
   // Get the patterns to apply
-  cv::Ptr<OrbPatterns> patterns = patterns_[level];
+  OrbPatterns* patterns = patterns_[level];
 
   //create the descriptor mat, keypoints.size() rows, BYTES cols
   descriptors = cv::Mat::zeros(keypoints.size(), kBytes, CV_8UC1);
index 3b75499..7910cdf 100644 (file)
@@ -398,7 +398,7 @@ protected:
             double t = (double)getTickCount();
             dextractor->compute( img, keypoints, calcDescriptors );
             t = getTickCount() - t;
-            ts->printf(cvtest::TS::LOG, "\nAverage time of computiting one descriptor = %g ms (previous time = %g ms).\n", t/((double)cvGetTickFrequency()*1000.)/calcDescriptors.rows, prevTime );
+            ts->printf(cvtest::TS::LOG, "\nAverage time of computing one descriptor = %g ms (previous time = %g ms).\n", t/((double)cvGetTickFrequency()*1000.)/calcDescriptors.rows, prevTime );
 
             if( calcDescriptors.rows != (int)keypoints.size() )
             {
@@ -1009,6 +1009,12 @@ TEST( Features2d_Detector_SURF, regression )
     test.safe_run();
 }
 
+TEST( Features2d_Detector_ORB, regression )
+{
+    CV_FeatureDetectorTest test( "detector-orb", FeatureDetector::create("ORB") );
+    test.safe_run();
+}
+
 TEST( Features2d_Detector_GridFAST, regression )
 {
     CV_FeatureDetectorTest test( "detector-grid-fast", FeatureDetector::create("GridFAST") );
@@ -1038,6 +1044,14 @@ TEST( Features2d_DescriptorExtractor_SURF, regression )
     test.safe_run();
 }
 
+TEST( Features2d_DescriptorExtractor_ORB, regression )
+{
+    // TODO adjust the parameters below
+    CV_DescriptorExtractorTest<L2<float> > test( "descriptor-orb",  0.035f,
+                                                 DescriptorExtractor::create("ORB"), 0.147372f );
+    test.safe_run();
+}
+
 TEST( Features2d_DescriptorExtractor_BRIEF, regression )
 {
     CV_DescriptorExtractorTest<Hamming> test( "descriptor-brief",  1,