mirror of
https://github.com/opencv/opencv.git
synced 2025-06-10 11:03:03 +08:00
samples: fix build without threading support
This commit is contained in:
parent
bd0732b1d0
commit
f77fdc0ce8
@ -114,6 +114,7 @@ else()
|
|||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
endif()
|
endif()
|
||||||
if((TARGET Threads::Threads OR HAVE_THREADS) AND NOT OPENCV_EXAMPLES_DISABLE_THREADS)
|
if((TARGET Threads::Threads OR HAVE_THREADS) AND NOT OPENCV_EXAMPLES_DISABLE_THREADS)
|
||||||
|
set(HAVE_THREADS 1)
|
||||||
add_definitions(-DHAVE_THREADS=1)
|
add_definitions(-DHAVE_THREADS=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -5,7 +5,11 @@
|
|||||||
#include <opencv2/imgproc.hpp>
|
#include <opencv2/imgproc.hpp>
|
||||||
#include <opencv2/highgui.hpp>
|
#include <opencv2/highgui.hpp>
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
#if defined(CV_CXX11) && defined(HAVE_THREADS)
|
||||||
|
#define USE_THREADS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_THREADS
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
@ -51,7 +55,7 @@ void drawPred(int classId, float conf, int left, int top, int right, int bottom,
|
|||||||
|
|
||||||
void callback(int pos, void* userdata);
|
void callback(int pos, void* userdata);
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
#ifdef USE_THREADS
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class QueueFPS : public std::queue<T>
|
class QueueFPS : public std::queue<T>
|
||||||
{
|
{
|
||||||
@ -101,7 +105,7 @@ private:
|
|||||||
TickMeter tm;
|
TickMeter tm;
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
};
|
};
|
||||||
#endif // CV_CXX11
|
#endif // USE_THREADS
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@ -166,7 +170,7 @@ int main(int argc, char** argv)
|
|||||||
else
|
else
|
||||||
cap.open(parser.get<int>("device"));
|
cap.open(parser.get<int>("device"));
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
#ifdef USE_THREADS
|
||||||
bool process = true;
|
bool process = true;
|
||||||
|
|
||||||
// Frames capturing thread
|
// Frames capturing thread
|
||||||
@ -266,7 +270,7 @@ int main(int argc, char** argv)
|
|||||||
framesThread.join();
|
framesThread.join();
|
||||||
processingThread.join();
|
processingThread.join();
|
||||||
|
|
||||||
#else // CV_CXX11
|
#else // USE_THREADS
|
||||||
if (async)
|
if (async)
|
||||||
CV_Error(Error::StsNotImplemented, "Asynchronous forward is supported only with Inference Engine backend.");
|
CV_Error(Error::StsNotImplemented, "Asynchronous forward is supported only with Inference Engine backend.");
|
||||||
|
|
||||||
@ -297,7 +301,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
imshow(kWinName, frame);
|
imshow(kWinName, frame);
|
||||||
}
|
}
|
||||||
#endif // CV_CXX11
|
#endif // USE_THREADS
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user