diff --git a/modules/xfeatures2d/CMakeLists.txt b/modules/xfeatures2d/CMakeLists.txt index 3c86ebc141b..8d0ce8e6af0 100644 --- a/modules/xfeatures2d/CMakeLists.txt +++ b/modules/xfeatures2d/CMakeLists.txt @@ -3,15 +3,21 @@ set(the_description "Contributed/Experimental Algorithms for Salient 2D Features if(HAVE_CUDA) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) endif() -ocv_define_module(xfeatures2d opencv_core opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_shape opencv_ml opencv_cudaarithm WRAP python java) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_vgg.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_boostdesc.cmake) set(DOWNLOAD_DIR "${OpenCV_BINARY_DIR}/downloads/xfeatures2d") + download_boost_descriptors("${DOWNLOAD_DIR}" boost_status) +if(boost_status) + add_definitions(-DHAS_BOOST_DOWNLOAD=1) +endif() + download_vgg_descriptors("${DOWNLOAD_DIR}" vgg_status) -if(NOT boost_status OR NOT vgg_status) - ocv_module_disable(xfeatures2d) +if(vgg_status) + add_definitions(-DHAS_VGG_DOWNLOAD=1) endif() +ocv_define_module(xfeatures2d opencv_core opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_shape opencv_ml opencv_cudaarithm WRAP python java) + ocv_module_include_directories("${DOWNLOAD_DIR}") diff --git a/modules/xfeatures2d/src/boostdesc.cpp b/modules/xfeatures2d/src/boostdesc.cpp index 3f7ee225fc9..3349d5aa642 100644 --- a/modules/xfeatures2d/src/boostdesc.cpp +++ b/modules/xfeatures2d/src/boostdesc.cpp @@ -65,6 +65,53 @@ namespace cv namespace xfeatures2d { +#ifndef HAS_BOOST_DOWNLOAD // cmake was not able to download external resources +class BoostDesc_Impl CV_FINAL : public BoostDesc +{ + +public: + explicit BoostDesc_Impl( int, bool, float) + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual ~BoostDesc_Impl() CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual int descriptorSize() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual int descriptorType() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual int defaultNorm() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual void compute(InputArray, vector&, OutputArray) + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual void setUseScaleOrientation(const bool) CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual bool getUseScaleOrientation() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual void setScaleFactor(const float) CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } + virtual float getScaleFactor() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without Boosting support"); + } +}; +#else /* !BoostDesc implementation */ @@ -737,3 +784,5 @@ Ptr BoostDesc::create( int desc, bool use_scale_orientation, float sc } // END NAMESPACE XFEATURES2D } // END NAMESPACE CV + +#endif // HAS_BOOST_DOWNLOAD diff --git a/modules/xfeatures2d/src/vgg.cpp b/modules/xfeatures2d/src/vgg.cpp index a187f6b1d7a..40c3761557c 100644 --- a/modules/xfeatures2d/src/vgg.cpp +++ b/modules/xfeatures2d/src/vgg.cpp @@ -66,6 +66,81 @@ namespace cv namespace xfeatures2d { +#ifndef HAS_VGG_DOWNLOAD + +class VGG_Impl CV_FINAL : public VGG +{ +public: + + // constructor + explicit VGG_Impl( int, float, bool, bool, float, bool) + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual ~VGG_Impl() CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual int descriptorSize() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual int descriptorType() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual int defaultNorm() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual void compute( InputArray, vector&, OutputArray ) CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual void setSigma(const float) CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual float getSigma() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual void setUseNormalizeImage(const bool) CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual bool getUseNormalizeImage() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual void setUseScaleOrientation(const bool) CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual bool getUseScaleOrientation() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual void setScaleFactor(const float) CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual float getScaleFactor() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual void setUseNormalizeDescriptor(const bool dsc_normalize) CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } + virtual bool getUseNormalizeDescriptor() const CV_OVERRIDE + { + CV_Error(cv::Error::NotSupported, "The library is built without VGG support"); + } +}; + +#else + /* !VGG implementation */ @@ -536,3 +611,5 @@ Ptr VGG::create( int desc, float isigma, bool img_normalize, bool use_scale } // END NAMESPACE XFEATURES2D } // END NAMESPACE CV + +#endif // HAS_VGG_DOWNLOAD