diff --git a/modules/gpunvidia/CMakeLists.txt b/modules/gpunvidia/CMakeLists.txt index 7c15424309..3f4e4f6a63 100644 --- a/modules/gpunvidia/CMakeLists.txt +++ b/modules/gpunvidia/CMakeLists.txt @@ -6,4 +6,4 @@ set(the_description "GPU-accelerated Computer Vision (HAL module)") ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations) -ocv_define_module(gpunvidia opencv_core opencv_objdetect) +ocv_define_module(gpunvidia opencv_core OPTIONAL opencv_objdetect) diff --git a/modules/gpunvidia/src/NCV.cpp b/modules/gpunvidia/src/NCV.cpp index c31f2a3b4f..be82423d08 100644 --- a/modules/gpunvidia/src/NCV.cpp +++ b/modules/gpunvidia/src/NCV.cpp @@ -737,6 +737,13 @@ struct RectConvert static void groupRectangles(std::vector &hypotheses, int groupThreshold, double eps, std::vector *weights) { +#ifndef HAVE_OPENCV_OBJDETECT + (void) hypotheses; + (void) groupThreshold; + (void) eps; + (void) weights; + CV_Error(cv::Error::StsNotImplemented, "This functionality requires objdetect module"); +#else std::vector rects(hypotheses.size()); std::transform(hypotheses.begin(), hypotheses.end(), rects.begin(), RectConvert()); @@ -752,6 +759,7 @@ static void groupRectangles(std::vector &hypotheses, int groupThresh } std::transform(rects.begin(), rects.end(), hypotheses.begin(), RectConvert()); hypotheses.resize(rects.size()); +#endif } diff --git a/modules/gpunvidia/src/cuda/NCVHaarObjectDetection.cu b/modules/gpunvidia/src/cuda/NCVHaarObjectDetection.cu index 9ab0194a4e..5296f24a31 100644 --- a/modules/gpunvidia/src/cuda/NCVHaarObjectDetection.cu +++ b/modules/gpunvidia/src/cuda/NCVHaarObjectDetection.cu @@ -61,7 +61,12 @@ #include "opencv2/core/cuda/warp.hpp" #include "opencv2/core/cuda/warp_shuffle.hpp" -#include "opencv2/objdetect.hpp" + +#include "opencv2/opencv_modules.hpp" + +#ifdef HAVE_OPENCV_OBJDETECT +# include "opencv2/objdetect.hpp" +#endif #include "opencv2/gpunvidia/NCV.hpp" #include "opencv2/gpunvidia/NPP_staging.hpp" @@ -2106,6 +2111,15 @@ static NCVStatus loadFromXML(const cv::String &filename, std::vector &haarClassifierNodes, std::vector &haarFeatures) { +#ifndef HAVE_OPENCV_OBJDETECT + (void) filename; + (void) haar; + (void) haarStages; + (void) haarClassifierNodes; + (void) haarFeatures; + CV_Error(cv::Error::StsNotImplemented, "This functionality requires objdetect module"); + return NCV_HAAR_XML_LOADING_EXCEPTION; +#else NCVStatus ncvStat; haar.NumStages = 0; @@ -2294,6 +2308,7 @@ static NCVStatus loadFromXML(const cv::String &filename, } return NCV_SUCCESS; +#endif } diff --git a/modules/gpunvidia/src/precomp.hpp b/modules/gpunvidia/src/precomp.hpp index c4e067f52d..106d0a3215 100644 --- a/modules/gpunvidia/src/precomp.hpp +++ b/modules/gpunvidia/src/precomp.hpp @@ -49,7 +49,12 @@ #include "opencv2/gpunvidia.hpp" #include "opencv2/core/utility.hpp" -#include "opencv2/objdetect.hpp" + +#include "opencv2/opencv_modules.hpp" + +#ifdef HAVE_OPENCV_OBJDETECT +# include "opencv2/objdetect.hpp" +#endif #include "opencv2/core/gpu_private.hpp" #include "opencv2/gpunvidia/private.hpp"