From 2c1af6fecf819e065a873c87c62ef178d218498c Mon Sep 17 00:00:00 2001 From: vasylslobodyan Date: Fri, 22 Apr 2016 09:29:41 +0100 Subject: [PATCH] Fix for alprd to allow input as /dev/video* where * is a number that corolate to the webcam on the system. Tested on OSX and Debian system (Ubuntu and RPI). --- src/main.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 190072f..f50c3f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,6 +161,31 @@ int main( int argc, const char** argv ) } } + else if (startsWith(filename, "/dev/video")) + { + int webcamnumber = 0; + if(filename.length() > 10) + { + std::string webcam_str_num; + for(int a = 11; a <= filename.length(); a=a+1) + { + webcam_str_num.append(filename,a,1); + } + int webcamnumber = atoi(webcam_str_num.c_str()); + } + else + { + std::cout << "Incorrect Webcam Address" << std::endl; + return 1; + } + int framenum = 0; + cv::VideoCapture cap(webcamnumber); + if (!cap.isOpened()) + { + std::cout << "Error opening webcam" << std::endl; + return 1; + } + } else if (filename == "webcam") { int framenum = 0;