Skip to content

Properly disable xfeatures2d if extra files cannot be downloaded #2815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions modules/xfeatures2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
49 changes: 49 additions & 0 deletions modules/xfeatures2d/src/boostdesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<KeyPoint>&, 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
*/
Expand Down Expand Up @@ -737,3 +784,5 @@ Ptr<BoostDesc> BoostDesc::create( int desc, bool use_scale_orientation, float sc

} // END NAMESPACE XFEATURES2D
} // END NAMESPACE CV

#endif // HAS_BOOST_DOWNLOAD
77 changes: 77 additions & 0 deletions modules/xfeatures2d/src/vgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<KeyPoint>&, 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
*/
Expand Down Expand Up @@ -536,3 +611,5 @@ Ptr<VGG> VGG::create( int desc, float isigma, bool img_normalize, bool use_scale

} // END NAMESPACE XFEATURES2D
} // END NAMESPACE CV

#endif // HAS_VGG_DOWNLOAD