Added support for webcam in the form of /dev/video[number] to alprd

This commit is contained in:
Matt Hill
2015-06-29 17:32:41 -04:00
parent d95730d40e
commit 9d1a8041bb

View File

@@ -108,7 +108,17 @@ void imageCollectionThread(void* arg)
cv::VideoCapture cap=cv::VideoCapture();
dispatcher->log_info("Video stream connecting...");
if (dispatcher->mjpeg_url == "webcam")
// Check if it's a webcam, if so, pass the device ID
std::string video_prefix = "/dev/video";
if (startsWith(dispatcher->mjpeg_url, video_prefix))
{
std::string device_number_str = dispatcher->mjpeg_url.substr(video_prefix.length());
dispatcher->log_info("Opening webcam video device " + device_number_str);
int webcam_number = atoi(device_number_str.c_str());
cap.open(webcam_number);
}
else if (dispatcher->mjpeg_url == "webcam")
{
cap.open(0);
}