Skip to content

Commit f398261

Browse files
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.
1 parent 9c0ae27 commit f398261

File tree

4 files changed

+38
-49
lines changed

4 files changed

+38
-49
lines changed

modules/xfeatures2d/include/opencv2/xfeatures2d.hpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,39 @@ namespace cv
6565
namespace xfeatures2d
6666
{
6767

68+
69+
/** @brief Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform
70+
(SIFT) algorithm by D. Lowe @cite Lowe04 .
71+
*/
72+
class CV_EXPORTS_W SIFT : public Feature2D
73+
{
74+
public:
75+
/**
76+
@param nfeatures The number of best features to retain. The features are ranked by their scores
77+
(measured in SIFT algorithm as the local contrast)
78+
79+
@param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. The
80+
number of octaves is computed automatically from the image resolution.
81+
82+
@param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform
83+
(low-contrast) regions. The larger the threshold, the less features are produced by the detector.
84+
85+
@param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning
86+
is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
87+
filtered out (more features are retained).
88+
89+
@param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image
90+
is captured with a weak camera with soft lenses, you might want to reduce the number.
91+
*/
92+
CV_WRAP static Ptr<SIFT> create(int nfeatures = 0, int nOctaveLayers = 3,
93+
double contrastThreshold = 0.04, double edgeThreshold = 10,
94+
double sigma = 1.6);
95+
};
96+
97+
typedef SIFT SiftFeatureDetector;
98+
typedef SIFT SiftDescriptorExtractor;
99+
100+
68101
//! @addtogroup xfeatures2d_experiment
69102
//! @{
70103

modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -50,40 +50,6 @@ namespace cv
5050
namespace xfeatures2d
5151
{
5252

53-
//! @addtogroup xfeatures2d_nonfree
54-
//! @{
55-
56-
/** @brief Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform
57-
(SIFT) algorithm by D. Lowe @cite Lowe04 .
58-
*/
59-
class CV_EXPORTS_W SIFT : public Feature2D
60-
{
61-
public:
62-
/**
63-
@param nfeatures The number of best features to retain. The features are ranked by their scores
64-
(measured in SIFT algorithm as the local contrast)
65-
66-
@param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. The
67-
number of octaves is computed automatically from the image resolution.
68-
69-
@param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform
70-
(low-contrast) regions. The larger the threshold, the less features are produced by the detector.
71-
72-
@param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning
73-
is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
74-
filtered out (more features are retained).
75-
76-
@param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image
77-
is captured with a weak camera with soft lenses, you might want to reduce the number.
78-
*/
79-
CV_WRAP static Ptr<SIFT> create( int nfeatures = 0, int nOctaveLayers = 3,
80-
double contrastThreshold = 0.04, double edgeThreshold = 10,
81-
double sigma = 1.6);
82-
};
83-
84-
typedef SIFT SiftFeatureDetector;
85-
typedef SIFT SiftDescriptorExtractor;
86-
8753
/** @brief Class for extracting Speeded Up Robust Features from an image @cite Bay06 .
8854
8955
The algorithm parameters:

modules/xfeatures2d/src/sift.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ namespace cv
114114
namespace xfeatures2d
115115
{
116116

117-
#ifdef OPENCV_ENABLE_NONFREE
118-
119117
/*!
120118
SIFT implementation.
121119
@@ -1202,14 +1200,5 @@ void SIFT_Impl::detectAndCompute(InputArray _image, InputArray _mask,
12021200
}
12031201
}
12041202

1205-
#else // ! #ifdef OPENCV_ENABLE_NONFREE
1206-
Ptr<SIFT> SIFT::create( int, int, double, double, double )
1207-
{
1208-
CV_Error(Error::StsNotImplemented,
1209-
"This algorithm is patented and is excluded in this configuration; "
1210-
"Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library");
1211-
}
1212-
#endif
1213-
12141203
}
12151204
}

modules/xfeatures2d/test/test_features2d.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -987,13 +987,13 @@ void CV_DescriptorMatcherTest::run( int )
987987
* Detectors
988988
*/
989989

990-
#ifdef OPENCV_ENABLE_NONFREE
991990
TEST( Features2d_Detector_SIFT, regression )
992991
{
993992
CV_FeatureDetectorTest test( "detector-sift", SIFT::create() );
994993
test.safe_run();
995994
}
996995

996+
#ifdef OPENCV_ENABLE_NONFREE
997997
TEST( Features2d_Detector_SURF, regression )
998998
{
999999
CV_FeatureDetectorTest test( "detector-surf", SURF::create() );
@@ -1028,14 +1028,14 @@ TEST( Features2d_Detector_Harris_Laplace_Affine, regression )
10281028
/*
10291029
* Descriptors
10301030
*/
1031-
#ifdef OPENCV_ENABLE_NONFREE
10321031
TEST( Features2d_DescriptorExtractor_SIFT, regression )
10331032
{
10341033
CV_DescriptorExtractorTest<L1<float> > test( "descriptor-sift", 1.0f,
10351034
SIFT::create() );
10361035
test.safe_run();
10371036
}
10381037

1038+
#ifdef OPENCV_ENABLE_NONFREE
10391039
TEST( Features2d_DescriptorExtractor_SURF, regression )
10401040
{
10411041
#ifdef HAVE_OPENCL
@@ -1334,8 +1334,9 @@ class CV_DetectPlanarTest : public cvtest::BaseTest
13341334
Ptr<Feature2D> f2d;
13351335
};
13361336

1337-
#ifdef OPENCV_ENABLE_NONFREE
13381337
TEST(Features2d_SIFTHomographyTest, regression) { CV_DetectPlanarTest test("SIFT", 80, SIFT::create()); test.safe_run(); }
1338+
1339+
#ifdef OPENCV_ENABLE_NONFREE
13391340
TEST(Features2d_SURFHomographyTest, regression) { CV_DetectPlanarTest test("SURF", 80, SURF::create()); test.safe_run(); }
13401341
#endif
13411342

@@ -1400,13 +1401,13 @@ class FeatureDetectorUsingMaskTest : public cvtest::BaseTest
14001401
Ptr<FeatureDetector> featureDetector_;
14011402
};
14021403

1403-
#ifdef OPENCV_ENABLE_NONFREE
14041404
TEST(Features2d_SIFT_using_mask, regression)
14051405
{
14061406
FeatureDetectorUsingMaskTest test(SIFT::create());
14071407
test.safe_run();
14081408
}
14091409

1410+
#ifdef OPENCV_ENABLE_NONFREE
14101411
TEST(DISABLED_Features2d_SURF_using_mask, regression)
14111412
{
14121413
FeatureDetectorUsingMaskTest test(SURF::create());

0 commit comments

Comments
 (0)