Added exception handling in videobuffer

This commit is contained in:
Matt Hill
2014-07-03 15:13:44 -04:00
parent 0efbcfcd07
commit c40648e27c
2 changed files with 48 additions and 31 deletions

View File

@@ -95,6 +95,10 @@ void imageCollectionThread(void* arg)
VideoDispatcher* dispatcher = (VideoDispatcher*) arg; VideoDispatcher* dispatcher = (VideoDispatcher*) arg;
while (dispatcher->active)
{
try
{
cv::VideoCapture cap=cv::VideoCapture(); cv::VideoCapture cap=cv::VideoCapture();
cap.open(dispatcher->mjpeg_url); cap.open(dispatcher->mjpeg_url);
@@ -135,3 +139,15 @@ void imageCollectionThread(void* arg)
usleep(100000); usleep(100000);
} }
} }
catch (const std::runtime_error& error)
{
// Error occured while trying to gather image. Retry, don't exit.
std::cerr << "VideoBuffer exception: " << error.what() << std::endl;
}
// Delay 1 second
usleep(1000000);
}
}

View File

@@ -2,6 +2,7 @@
#define OPENALPR_VIDEOBUFFER_H #define OPENALPR_VIDEOBUFFER_H
#include <cstdio> #include <cstdio>
#include <stdexcept>
#include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui/highgui.hpp"