mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-09 03:20:04 +08:00
Only lock when needed.
This commit is contained in:
@@ -154,7 +154,6 @@ void getALPRImages(cv::VideoCapture cap, VideoDispatcher* dispatcher)
|
|||||||
while (dispatcher->active)
|
while (dispatcher->active)
|
||||||
{
|
{
|
||||||
|
|
||||||
dispatcher->mMutex.lock();
|
|
||||||
bool hasImage = false;
|
bool hasImage = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -162,14 +161,15 @@ void getALPRImages(cv::VideoCapture cap, VideoDispatcher* dispatcher)
|
|||||||
// Double check the image to make sure it's valid.
|
// Double check the image to make sure it's valid.
|
||||||
if (!frame.data || frame.empty())
|
if (!frame.data || frame.empty())
|
||||||
{
|
{
|
||||||
dispatcher->mMutex.unlock();
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Stream " << dispatcher->mjpeg_url << " received invalid frame";
|
ss << "Stream " << dispatcher->mjpeg_url << " received invalid frame";
|
||||||
dispatcher->log_error(ss.str());
|
dispatcher->log_error(ss.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatcher->mMutex.lock();
|
||||||
dispatcher->setLatestFrame(&frame);
|
dispatcher->setLatestFrame(&frame);
|
||||||
|
dispatcher->mMutex.unlock();
|
||||||
}
|
}
|
||||||
catch (const std::runtime_error& error)
|
catch (const std::runtime_error& error)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user