From 11ce8683bb0c75fa3cfda270864574fc9e507f4d Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 18 Apr 2012 08:00:12 +0000 Subject: [PATCH] Fixed stitching module tests built without nonfree --- modules/stitching/perf/perf_stich.cpp | 13 ++++++++++--- modules/stitching/src/stitcher.cpp | 8 ++++++++ modules/stitching/test/test_matchers.cpp | 5 +++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/stitching/perf/perf_stich.cpp b/modules/stitching/perf/perf_stich.cpp index 81d8bc0913..1e91c805aa 100644 --- a/modules/stitching/perf/perf_stich.cpp +++ b/modules/stitching/perf/perf_stich.cpp @@ -2,6 +2,7 @@ #include "opencv2/highgui/highgui.hpp" #include "opencv2/flann/flann.hpp" +#include "opencv2/opencv_modules.hpp" using namespace std; using namespace cv; @@ -16,7 +17,13 @@ using std::tr1::get; typedef TestBaseWithParam stitch; typedef TestBaseWithParam match; -PERF_TEST_P(stitch, a123, testing::Values("surf", "orb")) +#if HAVE_OPENCV_NONFREE +#define TEST_DETECTORS testing::Values("surf", "orb") +#else +#define TEST_DETECTORS testing::Values("orb") +#endif + +PERF_TEST_P(stitch, a123, TEST_DETECTORS) { Mat pano; @@ -50,7 +57,7 @@ PERF_TEST_P(stitch, a123, testing::Values("surf", "orb")) } } -PERF_TEST_P(stitch, b12, testing::Values("surf", "orb")) +PERF_TEST_P(stitch, b12, TEST_DETECTORS) { Mat pano; @@ -83,7 +90,7 @@ PERF_TEST_P(stitch, b12, testing::Values("surf", "orb")) } } -PERF_TEST_P( match, bestOf2Nearest, testing::Values("surf", "orb")) +PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS) { Mat img1, img1_full = imread( getDataPath("stitching/b1.jpg") ); Mat img2, img2_full = imread( getDataPath("stitching/b2.jpg") ); diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp index b0ad8f1ec1..63f3284098 100644 --- a/modules/stitching/src/stitcher.cpp +++ b/modules/stitching/src/stitcher.cpp @@ -61,14 +61,22 @@ Stitcher Stitcher::createDefault(bool try_use_gpu) #ifdef HAVE_OPENCV_GPU if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0) { +#if HAVE_OPENCV_NONFREE stitcher.setFeaturesFinder(new detail::SurfFeaturesFinderGpu()); +#else + stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder()); +#endif stitcher.setWarper(new SphericalWarperGpu()); stitcher.setSeamFinder(new detail::GraphCutSeamFinderGpu()); } else #endif { +#if HAVE_OPENCV_NONFREE stitcher.setFeaturesFinder(new detail::SurfFeaturesFinder()); +#else + stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder()); +#endif stitcher.setWarper(new SphericalWarper()); stitcher.setSeamFinder(new detail::GraphCutSeamFinder(detail::GraphCutSeamFinderBase::COST_COLOR)); } diff --git a/modules/stitching/test/test_matchers.cpp b/modules/stitching/test/test_matchers.cpp index 9600d9dbbb..04d0ee2441 100644 --- a/modules/stitching/test/test_matchers.cpp +++ b/modules/stitching/test/test_matchers.cpp @@ -40,6 +40,9 @@ //M*/ #include "test_precomp.hpp" +#include "opencv2/opencv_modules.hpp" + +#if HAVE_OPENCV_NONFREE using namespace cv; using namespace std; @@ -71,3 +74,5 @@ TEST(SurfFeaturesFinder, CanFindInROIs) ASSERT_GT(br_rect_count, 0); ASSERT_EQ(bad_count, 0); } + +#endif \ No newline at end of file