mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 21:42:48 +08:00
Added try/catch handling around VideoCapture
This commit is contained in:
@@ -106,8 +106,21 @@ void imageCollectionThread(void* arg)
|
||||
{
|
||||
|
||||
dispatcher->mMutex.lock();
|
||||
bool hasImage = cap.read(frame);
|
||||
dispatcher->setLatestFrame(&frame);
|
||||
bool hasImage = false;
|
||||
try
|
||||
{
|
||||
hasImage = cap.read(frame);
|
||||
dispatcher->setLatestFrame(&frame);
|
||||
}
|
||||
catch (int e)
|
||||
{
|
||||
// Error occured while trying to gather image. Retry, don't exit.
|
||||
std::cerr << "Exception happened " << e << std::endl;
|
||||
}
|
||||
// Double check the image to make sure it's valid.
|
||||
if (frame.cols == 0 || frame.rows == 0)
|
||||
hasImage = false;
|
||||
|
||||
dispatcher->mMutex.unlock();
|
||||
|
||||
if (hasImage == false)
|
||||
|
Reference in New Issue
Block a user