mirror of
https://github.com/opencv/opencv.git
synced 2025-07-20 19:17:36 +08:00
Merge pull request #12398 from alalek:samples_eliminate_cvconfig
This commit is contained in:
commit
6aff916aa5
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <ctime>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "cvconfig.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cvconfig.h"
|
||||
|
||||
#include <va/va.h>
|
||||
# include <va/va_drm.h>
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user