diff --git a/src/video/videobuffer.cpp b/src/video/videobuffer.cpp index d9daa35..5a17391 100644 --- a/src/video/videobuffer.cpp +++ b/src/video/videobuffer.cpp @@ -154,7 +154,6 @@ void getALPRImages(cv::VideoCapture cap, VideoDispatcher* dispatcher) while (dispatcher->active) { - dispatcher->mMutex.lock(); bool hasImage = false; try { @@ -162,15 +161,16 @@ void getALPRImages(cv::VideoCapture cap, VideoDispatcher* dispatcher) // Double check the image to make sure it's valid. if (!frame.data || frame.empty()) { - dispatcher->mMutex.unlock(); std::stringstream ss; ss << "Stream " << dispatcher->mjpeg_url << " received invalid frame"; dispatcher->log_error(ss.str()); return; } + dispatcher->mMutex.lock(); dispatcher->setLatestFrame(&frame); - } + dispatcher->mMutex.unlock(); + } catch (const std::runtime_error& error) { // Error occured while trying to gather image. Retry, don't exit.