提交 2a07aa59 编写于 作者: G gineshidalgo99

Now working on OpenCV with Qt support

上级 8a963bda
......@@ -268,24 +268,27 @@ int opRealTimePoseDemo()
op::log("Starting thread(s)", op::Priority::Max);
// Option a) Recommended - Also using the main thread (this thread) for processing (it saves 1 thread)
// Start, run & stop threads
// opWrapper.exec(); // It blocks this thread until all threads have finished
opWrapper.exec(); // It blocks this thread until all threads have finished
// Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU memory
// Start threads
opWrapper.start();
// Profile used GPU memory
// 1: wait ~10sec so the memory has been totally loaded on GPU
// 2: profile the GPU memory
const auto sleepTimeMs = 10;
for (auto i = 0 ; i < 10000/sleepTimeMs && opWrapper.isRunning() ; i++)
std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs});
op::Profiler::profileGpuMemory(__LINE__, __FUNCTION__, __FILE__);
// Keep program alive while running threads
while (opWrapper.isRunning())
std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs});
// Stop and join threads
op::log("Stopping thread(s)", op::Priority::Max);
opWrapper.stop();
// // Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU memory
// // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main thread to
// // plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to:
// // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections`
// // Start threads
// opWrapper.start();
// // Profile used GPU memory
// // 1: wait ~10sec so the memory has been totally loaded on GPU
// // 2: profile the GPU memory
// const auto sleepTimeMs = 10;
// for (auto i = 0 ; i < 10000/sleepTimeMs && opWrapper.isRunning() ; i++)
// std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs});
// op::Profiler::profileGpuMemory(__LINE__, __FUNCTION__, __FILE__);
// // Keep program alive while running threads
// while (opWrapper.isRunning())
// std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs});
// // Stop and join threads
// op::log("Stopping thread(s)", op::Priority::Max);
// opWrapper.stop();
// Measuring total time
const auto totalTimeSec = (double)std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now()-timerBegin).count() * 1e-9;
......
......@@ -164,16 +164,19 @@ int openPoseTutorialThread1()
op::log("Starting thread(s)", op::Priority::Max);
// Two different ways of running the program on multithread enviroment
// Option a) Using the main thread (this thread) for processing (it saves 1 thread, recommended)
// threadManager.exec(); // It blocks this thread until all threads have finished
threadManager.exec(); // It blocks this thread until all threads have finished
// Option b) Giving to the user the control of this thread
// Start threads
threadManager.start();
// Keep program alive while running threads. Here the user could perform any other desired function
while (threadManager.isRunning())
std::this_thread::sleep_for(std::chrono::milliseconds{33});
// Stop and join threads
op::log("Stopping thread(s)", op::Priority::Max);
threadManager.stop();
// // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main thread to
// // plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to:
// // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections`
// // Start threads
// threadManager.start();
// // Keep program alive while running threads. Here the user could perform any other desired function
// while (threadManager.isRunning())
// std::this_thread::sleep_for(std::chrono::milliseconds{33});
// // Stop and join threads
// op::log("Stopping thread(s)", op::Priority::Max);
// threadManager.stop();
// ------------------------- CLOSING -------------------------
// Logging information message
......
......@@ -206,16 +206,19 @@ int openPoseTutorialThread2()
op::log("Starting thread(s)", op::Priority::Max);
// Two different ways of running the program on multithread enviroment
// Option a) Using the main thread (this thread) for processing (it saves 1 thread, recommended)
// threadManager.exec(); // It blocks this thread until all threads have finished
threadManager.exec(); // It blocks this thread until all threads have finished
// Option b) Giving to the user the control of this thread
// Start threads
threadManager.start();
// Keep program alive while running threads. Here the user could perform any other desired function
while (threadManager.isRunning())
std::this_thread::sleep_for(std::chrono::milliseconds{33});
// Stop and join threads
op::log("Stopping thread(s)", op::Priority::Max);
threadManager.stop();
// // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main thread to
// // plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to:
// // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections`
// // Start threads
// threadManager.start();
// // Keep program alive while running threads. Here the user could perform any other desired function
// while (threadManager.isRunning())
// std::this_thread::sleep_for(std::chrono::milliseconds{33});
// // Stop and join threads
// op::log("Stopping thread(s)", op::Priority::Max);
// threadManager.stop();
// ------------------------- CLOSING -------------------------
// Logging information message
......
......@@ -197,16 +197,19 @@ int openPoseTutorialThread3()
op::log("Starting thread(s)", op::Priority::Max);
// Two different ways of running the program on multithread enviroment
// Option a) Using the main thread (this thread) for processing (it saves 1 thread, recommended)
// threadManager.exec(); // It blocks this thread until all threads have finished
threadManager.exec(); // It blocks this thread until all threads have finished
// Option b) Giving to the user the control of this thread
// Start threads
threadManager.start();
// Keep program alive while running threads. Here the user could perform any other desired function
while (threadManager.isRunning())
std::this_thread::sleep_for(std::chrono::milliseconds{33});
// Stop and join threads
op::log("Stopping thread(s)", op::Priority::Max);
threadManager.stop();
// // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main thread to
// // plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to:
// // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections`
// // Start threads
// threadManager.start();
// // Keep program alive while running threads. Here the user could perform any other desired function
// while (threadManager.isRunning())
// std::this_thread::sleep_for(std::chrono::milliseconds{33});
// // Stop and join threads
// op::log("Stopping thread(s)", op::Priority::Max);
// threadManager.stop();
// ------------------------- CLOSING -------------------------
// Logging information message
......
......@@ -209,16 +209,19 @@ int openPoseTutorialThread4()
op::log("Starting thread(s)", op::Priority::Max);
// Two different ways of running the program on multithread enviroment
// Option a) Using the main thread (this thread) for processing (it saves 1 thread, recommended)
// threadManager.exec(); // It blocks this thread until all threads have finished
threadManager.exec(); // It blocks this thread until all threads have finished
// Option b) Giving to the user the control of this thread
// Start threads
threadManager.start();
// Keep program alive while running threads. Here the user could perform any other desired function
while (threadManager.isRunning())
std::this_thread::sleep_for(std::chrono::milliseconds{33});
// Stop and join threads
op::log("Stopping thread(s)", op::Priority::Max);
threadManager.stop();
// // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main thread to
// // plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to:
// // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections`
// // Start threads
// threadManager.start();
// // Keep program alive while running threads. Here the user could perform any other desired function
// while (threadManager.isRunning())
// std::this_thread::sleep_for(std::chrono::milliseconds{33});
// // Stop and join threads
// op::log("Stopping thread(s)", op::Priority::Max);
// threadManager.stop();
// ------------------------- CLOSING -------------------------
// Logging information message
......
......@@ -365,22 +365,25 @@ int openPoseTutorialWrapper2()
// Two different ways of running the program on multithread enviroment
// // Option a) Recommended - Also using the main thread (this thread) for processing (it saves 1 thread)
// // Start, run & stop threads
// opWrapper.exec(); // It blocks this thread until all threads have finished
opWrapper.exec(); // It blocks this thread until all threads have finished
// Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU memory
// Start threads
opWrapper.start();
// Profile used GPU memory
// 1: wait ~10sec so the memory has been totally loaded on GPU
// 2: profile the GPU memory
std::this_thread::sleep_for(std::chrono::milliseconds{1000});
op::log("Random task here...", op::Priority::Max);
// Keep program alive while running threads
while (opWrapper.isRunning())
std::this_thread::sleep_for(std::chrono::milliseconds{33});
// Stop and join threads
op::log("Stopping thread(s)", op::Priority::Max);
opWrapper.stop();
// // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main thread to
// // plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to:
// // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections`
// // Start threads
// opWrapper.start();
// // Profile used GPU memory
// // 1: wait ~10sec so the memory has been totally loaded on GPU
// // 2: profile the GPU memory
// std::this_thread::sleep_for(std::chrono::milliseconds{1000});
// op::log("Random task here...", op::Priority::Max);
// // Keep program alive while running threads
// while (opWrapper.isRunning())
// std::this_thread::sleep_for(std::chrono::milliseconds{33});
// // Stop and join threads
// op::log("Stopping thread(s)", op::Priority::Max);
// opWrapper.stop();
// Measuring total time
const auto totalTimeSec = (double)std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now()-timerBegin).count() * 1e-9;
......
......@@ -123,6 +123,10 @@ namespace op
* Function to start multi-threading.
* Similar to exec(), but start() does not block the thread that calls the function. It just opens new threads, so it
* lets the user perform other tasks meanwhile on the calling thread.
* VERY IMPORTANT NOTE: if the GUI is selected and OpenCV is compiled with Qt support, this option will not work. Qt
* needs the main thread to plot visual results, so the final GUI (which uses OpenCV) would return an exception
* similar to: `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections`. Use exec()
* in that case.
*/
void start();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册