\brief AsyncDetector::Process
| 55 | /// \brief AsyncDetector::Process |
| 56 | /// |
| 57 | void AsyncDetector::Process() |
| 58 | { |
| 59 | double freq = cv::getTickFrequency(); |
| 60 | int64 allTime = 0; |
| 61 | |
| 62 | bool stopFlag = false; |
| 63 | |
| 64 | std::thread thCapture(CaptureThread, m_inFile, m_startFrame, &m_framesCount, &m_fps, &m_framesQue, &stopFlag); |
| 65 | |
| 66 | #ifndef SILENT_WORK |
| 67 | cv::namedWindow("Video", cv::WINDOW_NORMAL | cv::WINDOW_KEEPRATIO); |
| 68 | cv::waitKey(1); |
| 69 | #endif |
| 70 | |
| 71 | cv::VideoWriter writer; |
| 72 | |
| 73 | int framesCounter = m_startFrame + 1; |
| 74 | |
| 75 | for (; !stopFlag;) |
| 76 | { |
| 77 | int64 t1 = cv::getTickCount(); |
| 78 | |
| 79 | // Show frame after detecting and tracking |
| 80 | frame_ptr processedFrame = m_framesQue.GetFirstProcessedFrame(); |
| 81 | if (!processedFrame) |
| 82 | { |
| 83 | stopFlag = true; |
| 84 | break; |
| 85 | } |
| 86 | |
| 87 | int64 t2 = cv::getTickCount(); |
| 88 | |
| 89 | allTime += t2 - processedFrame->m_dt; |
| 90 | int currTime = cvRound(1000 * (t2 - t1) / freq); |
| 91 | |
| 92 | DrawData(processedFrame, framesCounter, currTime); |
| 93 | |
| 94 | if (!m_outFile.empty()) |
| 95 | { |
| 96 | if (!writer.isOpened()) |
| 97 | writer.open(m_outFile, cv::VideoWriter::fourcc('H', 'F', 'Y', 'U'), m_fps, processedFrame->m_frame.size(), true); |
| 98 | if (writer.isOpened()) |
| 99 | writer << processedFrame->m_frame; |
| 100 | } |
| 101 | |
| 102 | #ifndef SILENT_WORK |
| 103 | cv::imshow("Video", processedFrame->m_frame); |
| 104 | |
| 105 | int waitTime = 1;// std::max<int>(1, cvRound(1000 / m_fps - currTime)); |
| 106 | int k = cv::waitKey(waitTime); |
| 107 | if (k == 27) |
| 108 | break; |
| 109 | #else |
| 110 | //std::this_thread::sleep_for(std::chrono::milliseconds(1)); |
| 111 | #endif |
| 112 | |
| 113 | ++framesCounter; |
| 114 | if (m_endFrame && framesCounter > m_endFrame) |