diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index 889c279615..3868def0df 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -195,40 +195,6 @@ void HarrisResponse::operator()(std::vector& 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& 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& 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 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); diff --git a/modules/features2d/test/test_features2d.cpp b/modules/features2d/test/test_features2d.cpp index 3b75499572..7910cdf4bd 100644 --- a/modules/features2d/test/test_features2d.cpp +++ b/modules/features2d/test/test_features2d.cpp @@ -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 > test( "descriptor-orb", 0.035f, + DescriptorExtractor::create("ORB"), 0.147372f ); + test.safe_run(); +} + TEST( Features2d_DescriptorExtractor_BRIEF, regression ) { CV_DescriptorExtractorTest test( "descriptor-brief", 1,