Merge pull request #2506 from alalek:move_sift

pull/2510/head^2
Alexander Alekhin 5 years ago
commit b31e55b6b5
  1. 2
      modules/README.md
  2. 2
      modules/xfeatures2d/README.md
  3. 11
      modules/xfeatures2d/doc/xfeatures2d.bib
  4. 33
      modules/xfeatures2d/include/opencv2/xfeatures2d.hpp
  5. 2
      modules/xfeatures2d/misc/python/pyopencv_sift.hpp
  6. 20
      modules/xfeatures2d/misc/python/shadow_sift.hpp
  7. 24
      modules/xfeatures2d/misc/python/test/test_sift_compatibility.py
  8. 72
      modules/xfeatures2d/perf/perf_sift.cpp
  9. 2
      modules/xfeatures2d/src/precomp.hpp
  10. 1232
      modules/xfeatures2d/src/sift.cpp
  11. 40
      modules/xfeatures2d/test/test_features2d.cpp
  12. 6
      modules/xfeatures2d/test/test_keypoints.cpp
  13. 37
      modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp

@ -64,7 +64,7 @@ $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_<r
- **tracking**: Vision Based Object Tracking -- Use and/or evaluate one of 5 different visual object tracking techniques.
- **xfeatures2d**: Features2D extra -- Extra 2D Features Framework containing experimental and non-free 2D feature detector/descriptor algorithms. SURF, SIFT, BRIEF, Censure, Freak, LUCID, Daisy, Self-similar.
- **xfeatures2d**: Features2D extra -- Extra 2D Features Framework containing experimental and non-free 2D feature detector/descriptor algorithms. SURF, BRIEF, Censure, Freak, LUCID, Daisy, Self-similar.
- **ximgproc**: Extended Image Processing -- Structured Forests / Domain Transform Filter / Guided Filter / Adaptive Manifold Filter / Joint Bilateral Filter / Superpixels / Ridge Detection Filter.

@ -5,4 +5,4 @@ Extra 2D Features Framework
2. Non-free 2D feature algorithms
Extra 2D Features Framework containing experimental and non-free 2D feature detector/descriptor algorithms:
SURF, SIFT, BRIEF, Censure, Freak, LUCID, Daisy, Self-similar.
SURF, BRIEF, Censure, Freak, LUCID, Daisy, Self-similar.

@ -60,17 +60,6 @@
year = {2016}
}
@article{Lowe04,
title = {Distinctive image features from scale-invariant keypoints},
author = {Lowe, David G},
journal = {International journal of computer vision},
volume = {60},
number = {2},
pages = {91--110},
year = {2004},
publisher = {Kluwer Academic Publishers}
}
@article{Mikolajczyk2004,
title = {Scale \& affine invariant interest point detectors},
author = {Mikolajczyk, Krystian and Schmid, Cordelia},

@ -65,39 +65,6 @@ namespace cv
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
//! @{

@ -0,0 +1,2 @@
// Compatibility
#include "shadow_sift.hpp"

@ -0,0 +1,20 @@
// Compatibility
// SIFT is moved to the main repository
namespace cv {
namespace xfeatures2d {
/** Use cv.SIFT_create() instead */
CV_WRAP static inline
Ptr<cv::SIFT> SIFT_create(int nfeatures = 0, int nOctaveLayers = 3,
double contrastThreshold = 0.04, double edgeThreshold = 10,
double sigma = 1.6)
{
CV_LOG_ONCE_WARNING(NULL, "DEPRECATED: cv.xfeatures2d.SIFT_create() is deprecated due SIFT tranfer to the main repository. "
"https://github.com/opencv/opencv/issues/16736"
);
return SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma);
}
}} // namespace

@ -0,0 +1,24 @@
#!/usr/bin/env python
# Python 2/3 compatibility
from __future__ import print_function
import os
import numpy as np
import cv2 as cv
from tests_common import NewOpenCVTests
class sift_compatibility_test(NewOpenCVTests):
def test_create(self):
sift = cv.xfeatures2d.SIFT_create()
self.assertFalse(sift is None)
img1 = np.zeros((100, 100, 3), dtype=np.uint8)
kp1_, des1_ = sift.detectAndCompute(img1, None)
if __name__ == '__main__':
NewOpenCVTests.bootstrap()

@ -1,72 +0,0 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test { namespace {
typedef perf::TestBaseWithParam<std::string> sift;
#define SIFT_IMAGES \
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
"stitching/a3.png"
PERF_TEST_P(sift, detect, testing::Values(SIFT_IMAGES))
{
string filename = getDataPath(GetParam());
Mat frame = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
Mat mask;
declare.in(frame).time(90);
Ptr<SIFT> detector = SIFT::create();
vector<KeyPoint> points;
PERF_SAMPLE_BEGIN();
detector->detect(frame, points, mask);
PERF_SAMPLE_END();
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(sift, extract, testing::Values(SIFT_IMAGES))
{
string filename = getDataPath(GetParam());
Mat frame = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
Mat mask;
declare.in(frame).time(90);
Ptr<SIFT> detector = SIFT::create();
vector<KeyPoint> points;
Mat descriptors;
detector->detect(frame, points, mask);
PERF_SAMPLE_BEGIN();
detector->compute(frame, points, descriptors);
PERF_SAMPLE_END();
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(sift, full, testing::Values(SIFT_IMAGES))
{
string filename = getDataPath(GetParam());
Mat frame = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
Mat mask;
declare.in(frame).time(90);
Ptr<SIFT> detector = SIFT::create();
vector<KeyPoint> points;
Mat descriptors;
PERF_SAMPLE_BEGIN();
detector->detectAndCompute(frame, mask, points, descriptors, false);
PERF_SAMPLE_END();
SANITY_CHECK_NOTHING();
}
}} // namespace

@ -61,6 +61,4 @@
#include "opencv2/core/private.hpp"
#define USE_AVX2 (cv::checkHardwareSupport(CV_CPU_AVX2))
#endif

File diff suppressed because it is too large Load Diff

@ -987,12 +987,6 @@ void CV_DescriptorMatcherTest::run( int )
* Detectors
*/
TEST( Features2d_Detector_SIFT, regression )
{
CV_FeatureDetectorTest test( "detector-sift", SIFT::create() );
test.safe_run();
}
#ifdef OPENCV_ENABLE_NONFREE
TEST( Features2d_Detector_SURF, regression )
{
@ -1028,12 +1022,6 @@ TEST( Features2d_Detector_Harris_Laplace_Affine, regression )
/*
* Descriptors
*/
TEST( Features2d_DescriptorExtractor_SIFT, regression )
{
CV_DescriptorExtractorTest<L1<float> > test( "descriptor-sift", 1.0f,
SIFT::create() );
test.safe_run();
}
#ifdef OPENCV_ENABLE_NONFREE
TEST( Features2d_DescriptorExtractor_SURF, regression )
@ -1413,34 +1401,6 @@ TEST(DISABLED_Features2d_SURF_using_mask, regression)
FeatureDetectorUsingMaskTest test(SURF::create());
test.safe_run();
}
TEST( XFeatures2d_DescriptorExtractor, batch )
{
string path = string(cvtest::TS::ptr()->get_data_path() + "detectors_descriptors_evaluation/images_datasets/graf");
vector<Mat> imgs, descriptors;
vector<vector<KeyPoint> > keypoints;
int i, n = 6;
Ptr<SIFT> sift = SIFT::create();
for( i = 0; i < n; i++ )
{
string imgname = format("%s/img%d.png", path.c_str(), i+1);
Mat img = imread(imgname, 0);
imgs.push_back(img);
}
sift->detect(imgs, keypoints);
sift->compute(imgs, keypoints, descriptors);
ASSERT_EQ((int)keypoints.size(), n);
ASSERT_EQ((int)descriptors.size(), n);
for( i = 0; i < n; i++ )
{
EXPECT_GT((int)keypoints[i].size(), 100);
EXPECT_GT(descriptors[i].rows, 100);
}
}
#endif // NONFREE
}} // namespace

@ -121,12 +121,6 @@ TEST(Features2d_Detector_Keypoints_SURF, validation)
CV_FeatureDetectorKeypointsTest test(xfeatures2d::SURF::create());
test.safe_run();
}
TEST(Features2d_Detector_Keypoints_SIFT, validation)
{
CV_FeatureDetectorKeypointsTest test(xfeatures2d::SIFT::create());
test.safe_run();
}
#endif // NONFREE

@ -610,14 +610,6 @@ TEST(Features2d_RotationInvariance_Detector_SURF, regression)
test.safe_run();
}
TEST(Features2d_RotationInvariance_Detector_SIFT, DISABLED_regression)
{
DetectorRotationInvarianceTest test(SIFT::create(),
0.45f,
0.70f);
test.safe_run();
}
/*
* Descriptors's rotation invariance check
*/
@ -629,15 +621,7 @@ TEST(Features2d_RotationInvariance_Descriptor_SURF, regression)
0.83f);
test.safe_run();
}
TEST(Features2d_RotationInvariance_Descriptor_SIFT, regression)
{
DescriptorRotationInvarianceTest test(SIFT::create(),
SIFT::create(),
NORM_L1,
0.98f);
test.safe_run();
}
#endif // NONFREE
TEST(Features2d_RotationInvariance_Descriptor_LATCH, regression)
{
@ -647,7 +631,6 @@ TEST(Features2d_RotationInvariance_Descriptor_LATCH, regression)
0.98f);
test.safe_run();
}
#endif // NONFREE
TEST(DISABLED_Features2d_RotationInvariance_Descriptor_DAISY, regression)
{
@ -806,14 +789,6 @@ TEST(Features2d_ScaleInvariance_Detector_SURF, regression)
test.safe_run();
}
TEST(Features2d_ScaleInvariance_Detector_SIFT, regression)
{
DetectorScaleInvarianceTest test(SIFT::create(),
0.69f,
0.98f);
test.safe_run();
}
/*
* Descriptor's scale invariance check
*/
@ -826,16 +801,6 @@ TEST(Features2d_ScaleInvariance_Descriptor_SURF, regression)
test.safe_run();
}
TEST(Features2d_ScaleInvariance_Descriptor_SIFT, regression)
{
DescriptorScaleInvarianceTest test(SIFT::create(),
SIFT::create(),
NORM_L1,
0.78f);
test.safe_run();
}
TEST(Features2d_RotationInvariance2_Detector_SURF, regression)
{
Mat cross(100, 100, CV_8UC1, Scalar(255));

Loading…
Cancel
Save