1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

samples: eliminate cvconfig.h usage

- don't use TBB in samples
This commit is contained in:
Alexander Alekhin
2018-09-03 18:56:04 +00:00
parent aa5c45339c
commit afb81ba6e6
6 changed files with 15 additions and 37 deletions
+3
View File
@@ -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()
@@ -2,7 +2,6 @@
#pragma warning( disable : 4201 4408 4127 4100)
#endif
#include "opencv2/cvconfig.h"
#include <iostream>
#include <iomanip>
#include <cstdio>
+12 -20
View File
@@ -7,29 +7,14 @@
#endif
#include <iostream>
#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;
}
-1
View File
@@ -9,7 +9,6 @@
#include <ctime>
#include <ctype.h>
#include "cvconfig.h"
#include <iostream>
#include <iomanip>
#include "opencv2/core/cuda.hpp"