Commit 29144436 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #9848 from jet47:features2d-optional-flann-dep

parents fef1f9b0 26fe8bd4
...@@ -392,6 +392,12 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2 ...@@ -392,6 +392,12 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2
void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f> &patternPoints, const std::vector<cv::Point2f> &rectifiedPatternPoints, std::vector<cv::Point2f> &centers) void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f> &patternPoints, const std::vector<cv::Point2f> &rectifiedPatternPoints, std::vector<cv::Point2f> &centers)
{ {
#ifndef HAVE_OPENCV_FLANN
(void)patternPoints;
(void)rectifiedPatternPoints;
(void)centers;
CV_Error(Error::StsNotImplemented, "The desired functionality requires flann module, which was disabled.");
#else
flann::LinearIndexParams flannIndexParams; flann::LinearIndexParams flannIndexParams;
flann::Index flannIndex(Mat(rectifiedPatternPoints).reshape(1), flannIndexParams); flann::Index flannIndex(Mat(rectifiedPatternPoints).reshape(1), flannIndexParams);
...@@ -425,6 +431,7 @@ void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f> ...@@ -425,6 +431,7 @@ void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f>
} }
} }
} }
#endif
} }
Graph::Graph(size_t n) Graph::Graph(size_t n)
......
...@@ -468,6 +468,8 @@ bool CV_ChessboardDetectorTest::checkByGenerator() ...@@ -468,6 +468,8 @@ bool CV_ChessboardDetectorTest::checkByGenerator()
TEST(Calib3d_ChessboardDetector, accuracy) { CV_ChessboardDetectorTest test( CHESSBOARD ); test.safe_run(); } TEST(Calib3d_ChessboardDetector, accuracy) { CV_ChessboardDetectorTest test( CHESSBOARD ); test.safe_run(); }
TEST(Calib3d_CirclesPatternDetector, accuracy) { CV_ChessboardDetectorTest test( CIRCLES_GRID ); test.safe_run(); } TEST(Calib3d_CirclesPatternDetector, accuracy) { CV_ChessboardDetectorTest test( CIRCLES_GRID ); test.safe_run(); }
TEST(Calib3d_AsymmetricCirclesPatternDetector, accuracy) { CV_ChessboardDetectorTest test( ASYMMETRIC_CIRCLES_GRID ); test.safe_run(); } TEST(Calib3d_AsymmetricCirclesPatternDetector, accuracy) { CV_ChessboardDetectorTest test( ASYMMETRIC_CIRCLES_GRID ); test.safe_run(); }
#ifdef HAVE_OPENCV_FLANN
TEST(Calib3d_AsymmetricCirclesPatternDetectorWithClustering, accuracy) { CV_ChessboardDetectorTest test( ASYMMETRIC_CIRCLES_GRID, CALIB_CB_CLUSTERING ); test.safe_run(); } TEST(Calib3d_AsymmetricCirclesPatternDetectorWithClustering, accuracy) { CV_ChessboardDetectorTest test( ASYMMETRIC_CIRCLES_GRID, CALIB_CB_CLUSTERING ); test.safe_run(); }
#endif
/* End of file. */ /* End of file. */
set(the_description "2D Features Framework") set(the_description "2D Features Framework")
ocv_define_module(features2d opencv_imgproc opencv_flann OPTIONAL opencv_highgui WRAP java python) ocv_define_module(features2d opencv_imgproc OPTIONAL opencv_flann opencv_highgui WRAP java python)
...@@ -43,8 +43,12 @@ ...@@ -43,8 +43,12 @@
#ifndef OPENCV_FEATURES_2D_HPP #ifndef OPENCV_FEATURES_2D_HPP
#define OPENCV_FEATURES_2D_HPP #define OPENCV_FEATURES_2D_HPP
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#ifdef HAVE_OPENCV_FLANN
#include "opencv2/flann/miniflann.hpp" #include "opencv2/flann/miniflann.hpp"
#endif
/** /**
@defgroup features2d 2D Features Framework @defgroup features2d 2D Features Framework
...@@ -1099,6 +1103,7 @@ protected: ...@@ -1099,6 +1103,7 @@ protected:
bool crossCheck; bool crossCheck;
}; };
#if defined(HAVE_OPENCV_FLANN) || defined(CV_DOXYGEN)
/** @brief Flann-based descriptor matcher. /** @brief Flann-based descriptor matcher.
...@@ -1145,6 +1150,8 @@ protected: ...@@ -1145,6 +1150,8 @@ protected:
int addedDescCount; int addedDescCount;
}; };
#endif
//! @} features2d_match //! @} features2d_match
/****************************************************************************************\ /****************************************************************************************\
......
...@@ -1005,11 +1005,14 @@ void BFMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vector<std:: ...@@ -1005,11 +1005,14 @@ void BFMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vector<std::
Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatcherType ) Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatcherType )
{ {
Ptr<DescriptorMatcher> dm; Ptr<DescriptorMatcher> dm;
#ifdef HAVE_OPENCV_FLANN
if( !descriptorMatcherType.compare( "FlannBased" ) ) if( !descriptorMatcherType.compare( "FlannBased" ) )
{ {
dm = makePtr<FlannBasedMatcher>(); dm = makePtr<FlannBasedMatcher>();
} }
else if( !descriptorMatcherType.compare( "BruteForce" ) ) // L2 else
#endif
if( !descriptorMatcherType.compare( "BruteForce" ) ) // L2
{ {
dm = makePtr<BFMatcher>(int(NORM_L2)); // anonymous enums can't be template parameters dm = makePtr<BFMatcher>(int(NORM_L2)); // anonymous enums can't be template parameters
} }
...@@ -1044,9 +1047,11 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType) ...@@ -1044,9 +1047,11 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType)
switch(matcherType) switch(matcherType)
{ {
#ifdef HAVE_OPENCV_FLANN
case FLANNBASED: case FLANNBASED:
name = "FlannBased"; name = "FlannBased";
break; break;
#endif
case BRUTEFORCE: case BRUTEFORCE:
name = "BruteForce"; name = "BruteForce";
break; break;
...@@ -1071,6 +1076,7 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType) ...@@ -1071,6 +1076,7 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType)
} }
#ifdef HAVE_OPENCV_FLANN
/* /*
* Flann based matcher * Flann based matcher
...@@ -1419,4 +1425,7 @@ void FlannBasedMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vect ...@@ -1419,4 +1425,7 @@ void FlannBasedMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vect
convertToDMatches( mergedDescriptors, indices, dists, matches ); convertToDMatches( mergedDescriptors, indices, dists, matches );
} }
#endif
} }
...@@ -536,12 +536,14 @@ TEST( Features2d_DescriptorMatcher_BruteForce, regression ) ...@@ -536,12 +536,14 @@ TEST( Features2d_DescriptorMatcher_BruteForce, regression )
test.safe_run(); test.safe_run();
} }
#ifdef HAVE_OPENCV_FLANN
TEST( Features2d_DescriptorMatcher_FlannBased, regression ) TEST( Features2d_DescriptorMatcher_FlannBased, regression )
{ {
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based",
DescriptorMatcher::create("FlannBased"), 0.04f ); DescriptorMatcher::create("FlannBased"), 0.04f );
test.safe_run(); test.safe_run();
} }
#endif
TEST( Features2d_DMatch, read_write ) TEST( Features2d_DMatch, read_write )
{ {
......
...@@ -49,7 +49,9 @@ ...@@ -49,7 +49,9 @@
using namespace std; using namespace std;
using namespace cv; using namespace cv;
#ifdef HAVE_OPENCV_FLANN
using namespace cv::flann; using namespace cv::flann;
#endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
class NearestNeighborTest : public cvtest::BaseTest class NearestNeighborTest : public cvtest::BaseTest
...@@ -158,6 +160,8 @@ void NearestNeighborTest::run( int /*start_from*/ ) { ...@@ -158,6 +160,8 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
#ifdef HAVE_OPENCV_FLANN
class CV_FlannTest : public NearestNeighborTest class CV_FlannTest : public NearestNeighborTest
{ {
public: public:
...@@ -331,3 +335,5 @@ TEST(Features2d_FLANN_KDTree, regression) { CV_FlannKDTreeIndexTest test; test.s ...@@ -331,3 +335,5 @@ TEST(Features2d_FLANN_KDTree, regression) { CV_FlannKDTreeIndexTest test; test.s
TEST(Features2d_FLANN_Composite, regression) { CV_FlannCompositeIndexTest test; test.safe_run(); } TEST(Features2d_FLANN_Composite, regression) { CV_FlannCompositeIndexTest test; test.safe_run(); }
TEST(Features2d_FLANN_Auto, regression) { CV_FlannAutotunedIndexTest test; test.safe_run(); } TEST(Features2d_FLANN_Auto, regression) { CV_FlannAutotunedIndexTest test; test.safe_run(); }
TEST(Features2d_FLANN_Saved, regression) { CV_FlannSavedIndexTest test; test.safe_run(); } TEST(Features2d_FLANN_Saved, regression) { CV_FlannSavedIndexTest test; test.safe_run(); }
#endif
...@@ -8,6 +8,6 @@ set(STITCHING_CONTRIB_DEPS "opencv_xfeatures2d") ...@@ -8,6 +8,6 @@ set(STITCHING_CONTRIB_DEPS "opencv_xfeatures2d")
if(BUILD_SHARED_LIBS AND BUILD_opencv_world AND OPENCV_WORLD_EXCLUDE_EXTRA_MODULES) if(BUILD_SHARED_LIBS AND BUILD_opencv_world AND OPENCV_WORLD_EXCLUDE_EXTRA_MODULES)
set(STITCHING_CONTRIB_DEPS "") set(STITCHING_CONTRIB_DEPS "")
endif() endif()
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_flann
OPTIONAL opencv_cudaarithm opencv_cudawarping opencv_cudafeatures2d opencv_cudalegacy ${STITCHING_CONTRIB_DEPS} OPTIONAL opencv_cudaarithm opencv_cudawarping opencv_cudafeatures2d opencv_cudalegacy ${STITCHING_CONTRIB_DEPS}
WRAP python) WRAP python)
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