mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-07 11:00:55 +08:00
Added try/catch handling around VideoCapture
This commit is contained in:
@@ -106,8 +106,21 @@ void imageCollectionThread(void* arg)
|
|||||||
{
|
{
|
||||||
|
|
||||||
dispatcher->mMutex.lock();
|
dispatcher->mMutex.lock();
|
||||||
bool hasImage = cap.read(frame);
|
bool hasImage = false;
|
||||||
dispatcher->setLatestFrame(&frame);
|
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();
|
dispatcher->mMutex.unlock();
|
||||||
|
|
||||||
if (hasImage == false)
|
if (hasImage == false)
|
||||||
|
Reference in New Issue
Block a user