1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

dnn: use AsyncArray

This commit is contained in:
Alexander Alekhin
2019-05-01 11:51:12 +00:00
parent 9340af1a8a
commit 132253c9f3
10 changed files with 66 additions and 124 deletions
+7 -4
View File
@@ -6,6 +6,7 @@
#include <opencv2/highgui.hpp>
#ifdef CV_CXX11
#include <mutex>
#include <thread>
#include <queue>
#endif
@@ -185,7 +186,7 @@ int main(int argc, char** argv)
QueueFPS<Mat> processedFramesQueue;
QueueFPS<std::vector<Mat> > predictionsQueue;
std::thread processingThread([&](){
std::queue<std::future<Mat> > futureOutputs;
std::queue<AsyncArray> futureOutputs;
Mat blob;
while (process)
{
@@ -224,11 +225,13 @@ int main(int argc, char** argv)
}
while (!futureOutputs.empty() &&
futureOutputs.front().wait_for(std::chrono::seconds(0)) == std::future_status::ready)
futureOutputs.front().wait_for(std::chrono::seconds(0)))
{
Mat out = futureOutputs.front().get();
predictionsQueue.push({out});
AsyncArray async_out = futureOutputs.front();
futureOutputs.pop();
Mat out;
async_out.get(out);
predictionsQueue.push({out});
}
}
});