Skip to content

Commit 2914443

Browse files
committed
Merge pull request opencv#9848 from jet47:features2d-optional-flann-dep
2 parents fef1f9b + 26fe8bd commit 2914443

File tree

8 files changed

+36
-3
lines changed

8 files changed

+36
-3
lines changed

modules/calib3d/src/circlesgrid.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2
392392

393393
void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f> &patternPoints, const std::vector<cv::Point2f> &rectifiedPatternPoints, std::vector<cv::Point2f> &centers)
394394
{
395+
#ifndef HAVE_OPENCV_FLANN
396+
(void)patternPoints;
397+
(void)rectifiedPatternPoints;
398+
(void)centers;
399+
CV_Error(Error::StsNotImplemented, "The desired functionality requires flann module, which was disabled.");
400+
#else
395401
flann::LinearIndexParams flannIndexParams;
396402
flann::Index flannIndex(Mat(rectifiedPatternPoints).reshape(1), flannIndexParams);
397403

@@ -425,6 +431,7 @@ void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f>
425431
}
426432
}
427433
}
434+
#endif
428435
}
429436

430437
Graph::Graph(size_t n)

modules/calib3d/test/test_chesscorners.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ bool CV_ChessboardDetectorTest::checkByGenerator()
468468
TEST(Calib3d_ChessboardDetector, accuracy) { CV_ChessboardDetectorTest test( CHESSBOARD ); test.safe_run(); }
469469
TEST(Calib3d_CirclesPatternDetector, accuracy) { CV_ChessboardDetectorTest test( CIRCLES_GRID ); test.safe_run(); }
470470
TEST(Calib3d_AsymmetricCirclesPatternDetector, accuracy) { CV_ChessboardDetectorTest test( ASYMMETRIC_CIRCLES_GRID ); test.safe_run(); }
471+
#ifdef HAVE_OPENCV_FLANN
471472
TEST(Calib3d_AsymmetricCirclesPatternDetectorWithClustering, accuracy) { CV_ChessboardDetectorTest test( ASYMMETRIC_CIRCLES_GRID, CALIB_CB_CLUSTERING ); test.safe_run(); }
473+
#endif
472474

473475
/* End of file. */

modules/features2d/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
set(the_description "2D Features Framework")
2-
ocv_define_module(features2d opencv_imgproc opencv_flann OPTIONAL opencv_highgui WRAP java python)
2+
ocv_define_module(features2d opencv_imgproc OPTIONAL opencv_flann opencv_highgui WRAP java python)

modules/features2d/include/opencv2/features2d.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@
4343
#ifndef OPENCV_FEATURES_2D_HPP
4444
#define OPENCV_FEATURES_2D_HPP
4545

46+
#include "opencv2/opencv_modules.hpp"
4647
#include "opencv2/core.hpp"
48+
49+
#ifdef HAVE_OPENCV_FLANN
4750
#include "opencv2/flann/miniflann.hpp"
51+
#endif
4852

4953
/**
5054
@defgroup features2d 2D Features Framework
@@ -1099,6 +1103,7 @@ class CV_EXPORTS_W BFMatcher : public DescriptorMatcher
10991103
bool crossCheck;
11001104
};
11011105

1106+
#if defined(HAVE_OPENCV_FLANN) || defined(CV_DOXYGEN)
11021107

11031108
/** @brief Flann-based descriptor matcher.
11041109
@@ -1145,6 +1150,8 @@ class CV_EXPORTS_W FlannBasedMatcher : public DescriptorMatcher
11451150
int addedDescCount;
11461151
};
11471152

1153+
#endif
1154+
11481155
//! @} features2d_match
11491156

11501157
/****************************************************************************************\

modules/features2d/src/matchers.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,11 +1005,14 @@ void BFMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vector<std::
10051005
Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatcherType )
10061006
{
10071007
Ptr<DescriptorMatcher> dm;
1008+
#ifdef HAVE_OPENCV_FLANN
10081009
if( !descriptorMatcherType.compare( "FlannBased" ) )
10091010
{
10101011
dm = makePtr<FlannBasedMatcher>();
10111012
}
1012-
else if( !descriptorMatcherType.compare( "BruteForce" ) ) // L2
1013+
else
1014+
#endif
1015+
if( !descriptorMatcherType.compare( "BruteForce" ) ) // L2
10131016
{
10141017
dm = makePtr<BFMatcher>(int(NORM_L2)); // anonymous enums can't be template parameters
10151018
}
@@ -1044,9 +1047,11 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType)
10441047

10451048
switch(matcherType)
10461049
{
1050+
#ifdef HAVE_OPENCV_FLANN
10471051
case FLANNBASED:
10481052
name = "FlannBased";
10491053
break;
1054+
#endif
10501055
case BRUTEFORCE:
10511056
name = "BruteForce";
10521057
break;
@@ -1071,6 +1076,7 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType)
10711076

10721077
}
10731078

1079+
#ifdef HAVE_OPENCV_FLANN
10741080

10751081
/*
10761082
* Flann based matcher
@@ -1419,4 +1425,7 @@ void FlannBasedMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vect
14191425

14201426
convertToDMatches( mergedDescriptors, indices, dists, matches );
14211427
}
1428+
1429+
#endif
1430+
14221431
}

modules/features2d/test/test_matchers_algorithmic.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,14 @@ TEST( Features2d_DescriptorMatcher_BruteForce, regression )
536536
test.safe_run();
537537
}
538538

539+
#ifdef HAVE_OPENCV_FLANN
539540
TEST( Features2d_DescriptorMatcher_FlannBased, regression )
540541
{
541542
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based",
542543
DescriptorMatcher::create("FlannBased"), 0.04f );
543544
test.safe_run();
544545
}
546+
#endif
545547

546548
TEST( Features2d_DMatch, read_write )
547549
{

modules/features2d/test/test_nearestneighbors.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949

5050
using namespace std;
5151
using namespace cv;
52+
#ifdef HAVE_OPENCV_FLANN
5253
using namespace cv::flann;
54+
#endif
5355

5456
//--------------------------------------------------------------------------------
5557
class NearestNeighborTest : public cvtest::BaseTest
@@ -158,6 +160,8 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
158160
}
159161

160162
//--------------------------------------------------------------------------------
163+
#ifdef HAVE_OPENCV_FLANN
164+
161165
class CV_FlannTest : public NearestNeighborTest
162166
{
163167
public:
@@ -331,3 +335,5 @@ TEST(Features2d_FLANN_KDTree, regression) { CV_FlannKDTreeIndexTest test; test.s
331335
TEST(Features2d_FLANN_Composite, regression) { CV_FlannCompositeIndexTest test; test.safe_run(); }
332336
TEST(Features2d_FLANN_Auto, regression) { CV_FlannAutotunedIndexTest test; test.safe_run(); }
333337
TEST(Features2d_FLANN_Saved, regression) { CV_FlannSavedIndexTest test; test.safe_run(); }
338+
339+
#endif

modules/stitching/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ set(STITCHING_CONTRIB_DEPS "opencv_xfeatures2d")
88
if(BUILD_SHARED_LIBS AND BUILD_opencv_world AND OPENCV_WORLD_EXCLUDE_EXTRA_MODULES)
99
set(STITCHING_CONTRIB_DEPS "")
1010
endif()
11-
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d
11+
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_flann
1212
OPTIONAL opencv_cudaarithm opencv_cudawarping opencv_cudafeatures2d opencv_cudalegacy ${STITCHING_CONTRIB_DEPS}
1313
WRAP python)

0 commit comments

Comments
 (0)