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
+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;
}