Commit 6aff916a authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #12398 from alalek:samples_eliminate_cvconfig

parents 4f9db2c0 afb81ba6
...@@ -30,6 +30,9 @@ if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND) ...@@ -30,6 +30,9 @@ if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
endif() endif()
project(gpu_samples) project(gpu_samples)
if(HAVE_CUDA OR CUDA_FOUND)
add_definitions(-DHAVE_CUDA=1)
endif()
if(COMMAND ocv_warnings_disable) if(COMMAND ocv_warnings_disable)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wsuggest-override -Winconsistent-missing-override) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wsuggest-override -Winconsistent-missing-override)
endif() endif()
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#pragma warning( disable : 4201 4408 4127 4100) #pragma warning( disable : 4201 4408 4127 4100)
#endif #endif
#include "opencv2/cvconfig.h"
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <cstdio> #include <cstdio>
......
...@@ -7,29 +7,14 @@ ...@@ -7,29 +7,14 @@
#endif #endif
#include <iostream> #include <iostream>
#include "opencv2/cvconfig.h"
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#include "opencv2/cudaarithm.hpp" #include "opencv2/cudaarithm.hpp"
#ifdef HAVE_TBB #if !defined(HAVE_CUDA)
# include "tbb/tbb.h"
# include "tbb/task.h"
# undef min
# undef max
#endif
#if !defined(HAVE_CUDA) || !defined(HAVE_TBB)
int main() int main()
{ {
#if !defined(HAVE_CUDA) std::cout << "CUDA support is required (OpenCV CMake parameter 'WITH_CUDA' must be true)." << std::endl;
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
return 0; return 0;
} }
...@@ -39,7 +24,14 @@ using namespace std; ...@@ -39,7 +24,14 @@ using namespace std;
using namespace cv; using namespace cv;
using namespace cv::cuda; 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() int main()
{ {
...@@ -64,8 +56,8 @@ int main() ...@@ -64,8 +56,8 @@ int main()
} }
// Execute calculation in two threads using two GPUs // Execute calculation in two threads using two GPUs
int devices[] = {0, 1}; cv::Range devices(0, 2);
tbb::parallel_do(devices, devices + 2, Worker()); cv::parallel_for_(devices, Worker(), devices.size());
return 0; return 0;
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <ctime> #include <ctime>
#include <ctype.h> #include <ctype.h>
#include "cvconfig.h"
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include "opencv2/core/cuda.hpp" #include "opencv2/core/cuda.hpp"
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include "cvconfig.h"
#include <va/va.h> #include <va/va.h>
# include <va/va_drm.h> # include <va/va_drm.h>
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/core/va_intel.hpp" #include "opencv2/core/va_intel.hpp"
#include "cvconfig.h"
#define CHECK_VASTATUS(_status,_func) \ #define CHECK_VASTATUS(_status,_func) \
if (_status != VA_STATUS_SUCCESS) \ if (_status != VA_STATUS_SUCCESS) \
...@@ -65,15 +64,9 @@ public: ...@@ -65,15 +64,9 @@ public:
void usage() void usage()
{ {
fprintf(stderr, fprintf(stderr,
#if defined(HAVE_VA_INTEL)
"Usage: va_intel_interop [-f] infile outfile1 outfile2\n\n" "Usage: va_intel_interop [-f] infile outfile1 outfile2\n\n"
"Interop ON/OFF version\n\n" "Interop ON/OFF version\n\n"
"where: -f option indicates interop is off (fallback mode); interop is on by default\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" " 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" " outfile1 is to be created, contains original surface data (NV12)\n"
" outfile2 is to be created, contains processed surface data (NV12)\n"); " outfile2 is to be created, contains processed surface data (NV12)\n");
...@@ -84,20 +77,14 @@ public: ...@@ -84,20 +77,14 @@ public:
int n = 0; int n = 0;
for (int i = 0; i < _fnNumFiles; ++i) for (int i = 0; i < _fnNumFiles; ++i)
m_files[i] = 0; m_files[i] = 0;
#if defined(HAVE_VA_INTEL)
m_interop = true; m_interop = true;
#elif defined(HAVE_VA)
m_interop = false;
#endif //HAVE_VA_INTEL / HAVE_VA
for (int i = 1; i < m_argc; ++i) for (int i = 1; i < m_argc; ++i)
{ {
const char *arg = m_argv[i]; const char *arg = m_argv[i];
if (arg[0] == '-') // option if (arg[0] == '-') // option
{ {
#if defined(HAVE_VA_INTEL)
if (!strcmp(arg, "-f")) if (!strcmp(arg, "-f"))
m_interop = false; m_interop = false;
#endif //HAVE_VA_INTEL
} }
else // parameter else // parameter
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment