@@ -51,7 +51,6 @@ void AsyncDetector::Process()
5151 bool stopFlag = false ;
5252
5353 std::thread thCapture (CaptureThread, m_inFile, m_startFrame, &m_fps, &m_framesQue, &stopFlag);
54- thCapture.detach ();
5554
5655 cv::namedWindow (" Video" , cv::WINDOW_NORMAL | cv::WINDOW_KEEPRATIO );
5756
@@ -308,9 +307,7 @@ void AsyncDetector::CaptureThread(std::string fileName, int startFrame, float* f
308307 cv::cvtColor (firstFrame, firstGray, cv::COLOR_BGR2GRAY );
309308
310309 std::thread thDetection (DetectThread, detectorConfig, firstGray, framesQue, stopFlag);
311- thDetection.detach ();
312310 std::thread thTracking (TrackingThread, trackerSettings, framesQue, stopFlag);
313- thTracking.detach ();
314311
315312 // Capture frame
316313 for (; !(*stopFlag);)
@@ -322,6 +319,7 @@ void AsyncDetector::CaptureThread(std::string fileName, int startFrame, float* f
322319 {
323320 std::cerr << " Frame is empty!" << std::endl;
324321 *stopFlag = true ;
322+ framesQue->SetBreak (true );
325323 break ;
326324 }
327325 if (frameInfo->m_clFrame .empty ())
@@ -335,14 +333,14 @@ void AsyncDetector::CaptureThread(std::string fileName, int startFrame, float* f
335333 std::this_thread::sleep_for (std::chrono::milliseconds (1000 / cvRound (*fps)));
336334 }
337335
338- if (thDetection.joinable ())
339- {
340- thDetection.join ();
341- }
342336 if (thTracking.joinable ())
343337 {
344338 thTracking.join ();
345339 }
340+ if (thDetection.joinable ())
341+ {
342+ thDetection.join ();
343+ }
346344}
347345
348346// /
0 commit comments