Unverified Commit f3982616 authored by RAJKIRAN NATARAJAN's avatar RAJKIRAN NATARAJAN Committed by GitHub

Merge pull request #2449 from saskatchewancatch:issue-16736

* issue-16736: quick step towards moving SIFT from non-free to free. Moves
include, tests, and implementation to free area.
parent 9c0ae273
...@@ -65,6 +65,39 @@ namespace cv ...@@ -65,6 +65,39 @@ namespace cv
namespace xfeatures2d namespace xfeatures2d
{ {
/** @brief Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform
(SIFT) algorithm by D. Lowe @cite Lowe04 .
*/
class CV_EXPORTS_W SIFT : public Feature2D
{
public:
/**
@param nfeatures The number of best features to retain. The features are ranked by their scores
(measured in SIFT algorithm as the local contrast)
@param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. The
number of octaves is computed automatically from the image resolution.
@param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform
(low-contrast) regions. The larger the threshold, the less features are produced by the detector.
@param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning
is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
filtered out (more features are retained).
@param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image
is captured with a weak camera with soft lenses, you might want to reduce the number.
*/
CV_WRAP static Ptr<SIFT> create(int nfeatures = 0, int nOctaveLayers = 3,
double contrastThreshold = 0.04, double edgeThreshold = 10,
double sigma = 1.6);
};
typedef SIFT SiftFeatureDetector;
typedef SIFT SiftDescriptorExtractor;
//! @addtogroup xfeatures2d_experiment //! @addtogroup xfeatures2d_experiment
//! @{ //! @{
......
...@@ -50,40 +50,6 @@ namespace cv ...@@ -50,40 +50,6 @@ namespace cv
namespace xfeatures2d namespace xfeatures2d
{ {
//! @addtogroup xfeatures2d_nonfree
//! @{
/** @brief Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform
(SIFT) algorithm by D. Lowe @cite Lowe04 .
*/
class CV_EXPORTS_W SIFT : public Feature2D
{
public:
/**
@param nfeatures The number of best features to retain. The features are ranked by their scores
(measured in SIFT algorithm as the local contrast)
@param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. The
number of octaves is computed automatically from the image resolution.
@param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform
(low-contrast) regions. The larger the threshold, the less features are produced by the detector.
@param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning
is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
filtered out (more features are retained).
@param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image
is captured with a weak camera with soft lenses, you might want to reduce the number.
*/
CV_WRAP static Ptr<SIFT> create( int nfeatures = 0, int nOctaveLayers = 3,
double contrastThreshold = 0.04, double edgeThreshold = 10,
double sigma = 1.6);
};
typedef SIFT SiftFeatureDetector;
typedef SIFT SiftDescriptorExtractor;
/** @brief Class for extracting Speeded Up Robust Features from an image @cite Bay06 . /** @brief Class for extracting Speeded Up Robust Features from an image @cite Bay06 .
The algorithm parameters: The algorithm parameters:
......
...@@ -114,8 +114,6 @@ namespace cv ...@@ -114,8 +114,6 @@ namespace cv
namespace xfeatures2d namespace xfeatures2d
{ {
#ifdef OPENCV_ENABLE_NONFREE
/*! /*!
SIFT implementation. SIFT implementation.
...@@ -1202,14 +1200,5 @@ void SIFT_Impl::detectAndCompute(InputArray _image, InputArray _mask, ...@@ -1202,14 +1200,5 @@ void SIFT_Impl::detectAndCompute(InputArray _image, InputArray _mask,
} }
} }
#else // ! #ifdef OPENCV_ENABLE_NONFREE
Ptr<SIFT> SIFT::create( int, int, double, double, double )
{
CV_Error(Error::StsNotImplemented,
"This algorithm is patented and is excluded in this configuration; "
"Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library");
}
#endif
} }
} }
...@@ -987,13 +987,13 @@ void CV_DescriptorMatcherTest::run( int ) ...@@ -987,13 +987,13 @@ void CV_DescriptorMatcherTest::run( int )
* Detectors * Detectors
*/ */
#ifdef OPENCV_ENABLE_NONFREE
TEST( Features2d_Detector_SIFT, regression ) TEST( Features2d_Detector_SIFT, regression )
{ {
CV_FeatureDetectorTest test( "detector-sift", SIFT::create() ); CV_FeatureDetectorTest test( "detector-sift", SIFT::create() );
test.safe_run(); test.safe_run();
} }
#ifdef OPENCV_ENABLE_NONFREE
TEST( Features2d_Detector_SURF, regression ) TEST( Features2d_Detector_SURF, regression )
{ {
CV_FeatureDetectorTest test( "detector-surf", SURF::create() ); CV_FeatureDetectorTest test( "detector-surf", SURF::create() );
...@@ -1028,7 +1028,6 @@ TEST( Features2d_Detector_Harris_Laplace_Affine, regression ) ...@@ -1028,7 +1028,6 @@ TEST( Features2d_Detector_Harris_Laplace_Affine, regression )
/* /*
* Descriptors * Descriptors
*/ */
#ifdef OPENCV_ENABLE_NONFREE
TEST( Features2d_DescriptorExtractor_SIFT, regression ) TEST( Features2d_DescriptorExtractor_SIFT, regression )
{ {
CV_DescriptorExtractorTest<L1<float> > test( "descriptor-sift", 1.0f, CV_DescriptorExtractorTest<L1<float> > test( "descriptor-sift", 1.0f,
...@@ -1036,6 +1035,7 @@ TEST( Features2d_DescriptorExtractor_SIFT, regression ) ...@@ -1036,6 +1035,7 @@ TEST( Features2d_DescriptorExtractor_SIFT, regression )
test.safe_run(); test.safe_run();
} }
#ifdef OPENCV_ENABLE_NONFREE
TEST( Features2d_DescriptorExtractor_SURF, regression ) TEST( Features2d_DescriptorExtractor_SURF, regression )
{ {
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
...@@ -1334,8 +1334,9 @@ protected: ...@@ -1334,8 +1334,9 @@ protected:
Ptr<Feature2D> f2d; Ptr<Feature2D> f2d;
}; };
#ifdef OPENCV_ENABLE_NONFREE
TEST(Features2d_SIFTHomographyTest, regression) { CV_DetectPlanarTest test("SIFT", 80, SIFT::create()); test.safe_run(); } TEST(Features2d_SIFTHomographyTest, regression) { CV_DetectPlanarTest test("SIFT", 80, SIFT::create()); test.safe_run(); }
#ifdef OPENCV_ENABLE_NONFREE
TEST(Features2d_SURFHomographyTest, regression) { CV_DetectPlanarTest test("SURF", 80, SURF::create()); test.safe_run(); } TEST(Features2d_SURFHomographyTest, regression) { CV_DetectPlanarTest test("SURF", 80, SURF::create()); test.safe_run(); }
#endif #endif
...@@ -1400,13 +1401,13 @@ protected: ...@@ -1400,13 +1401,13 @@ protected:
Ptr<FeatureDetector> featureDetector_; Ptr<FeatureDetector> featureDetector_;
}; };
#ifdef OPENCV_ENABLE_NONFREE
TEST(Features2d_SIFT_using_mask, regression) TEST(Features2d_SIFT_using_mask, regression)
{ {
FeatureDetectorUsingMaskTest test(SIFT::create()); FeatureDetectorUsingMaskTest test(SIFT::create());
test.safe_run(); test.safe_run();
} }
#ifdef OPENCV_ENABLE_NONFREE
TEST(DISABLED_Features2d_SURF_using_mask, regression) TEST(DISABLED_Features2d_SURF_using_mask, regression)
{ {
FeatureDetectorUsingMaskTest test(SURF::create()); FeatureDetectorUsingMaskTest test(SURF::create());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment