diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt index 0a3a2d0531..1c65145aca 100644 --- a/samples/gpu/CMakeLists.txt +++ b/samples/gpu/CMakeLists.txt @@ -30,6 +30,9 @@ if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND) endif() project(gpu_samples) +if(HAVE_CUDA OR CUDA_FOUND) + add_definitions(-DHAVE_CUDA=1) +endif() if(COMMAND ocv_warnings_disable) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wsuggest-override -Winconsistent-missing-override) endif() diff --git a/samples/gpu/cascadeclassifier_nvidia_api.cpp b/samples/gpu/cascadeclassifier_nvidia_api.cpp index f3d58cae5a..c932411eda 100644 --- a/samples/gpu/cascadeclassifier_nvidia_api.cpp +++ b/samples/gpu/cascadeclassifier_nvidia_api.cpp @@ -2,7 +2,6 @@ #pragma warning( disable : 4201 4408 4127 4100) #endif -#include "opencv2/cvconfig.h" #include #include #include diff --git a/samples/gpu/multi.cpp b/samples/gpu/multi.cpp index c3aac72d50..c3ef9b9641 100644 --- a/samples/gpu/multi.cpp +++ b/samples/gpu/multi.cpp @@ -7,29 +7,14 @@ #endif #include -#include "opencv2/cvconfig.h" #include "opencv2/core.hpp" #include "opencv2/cudaarithm.hpp" -#ifdef HAVE_TBB -# include "tbb/tbb.h" -# include "tbb/task.h" -# undef min -# undef max -#endif - -#if !defined(HAVE_CUDA) || !defined(HAVE_TBB) +#if !defined(HAVE_CUDA) int main() { -#if !defined(HAVE_CUDA) - std::cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true).\n"; -#endif - -#if !defined(HAVE_TBB) - std::cout << "TBB support is required (CMake key 'WITH_TBB' must be true).\n"; -#endif - + std::cout << "CUDA support is required (OpenCV CMake parameter 'WITH_CUDA' must be true)." << std::endl; return 0; } @@ -39,7 +24,14 @@ using namespace std; using namespace cv; using namespace cv::cuda; -struct Worker { void operator()(int device_id) const; }; +struct Worker : public cv::ParallelLoopBody +{ + void operator()(const Range& r) const CV_OVERRIDE + { + for (int i = r.start; i < r.end; ++i) { this->operator()(i); } + } + void operator()(int device_id) const; +}; int main() { @@ -64,8 +56,8 @@ int main() } // Execute calculation in two threads using two GPUs - int devices[] = {0, 1}; - tbb::parallel_do(devices, devices + 2, Worker()); + cv::Range devices(0, 2); + cv::parallel_for_(devices, Worker(), devices.size()); return 0; } diff --git a/samples/gpu/opticalflow_nvidia_api.cpp b/samples/gpu/opticalflow_nvidia_api.cpp index a60a7a8b46..0d924ec85e 100644 --- a/samples/gpu/opticalflow_nvidia_api.cpp +++ b/samples/gpu/opticalflow_nvidia_api.cpp @@ -9,7 +9,6 @@ #include #include -#include "cvconfig.h" #include #include #include "opencv2/core/cuda.hpp" diff --git a/samples/va_intel/display.cpp.inc b/samples/va_intel/display.cpp.inc index 56e71d26e2..6fd3e0cbf0 100644 --- a/samples/va_intel/display.cpp.inc +++ b/samples/va_intel/display.cpp.inc @@ -7,8 +7,6 @@ #include #include -#include "cvconfig.h" - #include # include diff --git a/samples/va_intel/va_intel_interop.cpp b/samples/va_intel/va_intel_interop.cpp index 8fa2c54f6f..770e9dbf41 100644 --- a/samples/va_intel/va_intel_interop.cpp +++ b/samples/va_intel/va_intel_interop.cpp @@ -45,7 +45,6 @@ #include "opencv2/imgproc.hpp" #include "opencv2/highgui.hpp" #include "opencv2/core/va_intel.hpp" -#include "cvconfig.h" #define CHECK_VASTATUS(_status,_func) \ if (_status != VA_STATUS_SUCCESS) \ @@ -65,15 +64,9 @@ public: void usage() { fprintf(stderr, -#if defined(HAVE_VA_INTEL) "Usage: va_intel_interop [-f] infile outfile1 outfile2\n\n" "Interop ON/OFF version\n\n" "where: -f option indicates interop is off (fallback mode); interop is on by default\n" -#elif defined(HAVE_VA) - "Usage: va_intel_interop infile outfile1 outfile2\n\n" - "Interop OFF only version\n\n" - "where:\n" -#endif //HAVE_VA_INTEL / HAVE_VA " infile is to be existing, contains input image data (bmp, jpg, png, tiff, etc)\n" " outfile1 is to be created, contains original surface data (NV12)\n" " outfile2 is to be created, contains processed surface data (NV12)\n"); @@ -84,20 +77,14 @@ public: int n = 0; for (int i = 0; i < _fnNumFiles; ++i) m_files[i] = 0; -#if defined(HAVE_VA_INTEL) m_interop = true; -#elif defined(HAVE_VA) - m_interop = false; -#endif //HAVE_VA_INTEL / HAVE_VA for (int i = 1; i < m_argc; ++i) { const char *arg = m_argv[i]; if (arg[0] == '-') // option { -#if defined(HAVE_VA_INTEL) if (!strcmp(arg, "-f")) m_interop = false; -#endif //HAVE_VA_INTEL } else // parameter {