Implements issue #187 -- Support wildcards in alpr executable

This commit is contained in:
Matt Hill
2015-08-27 20:54:41 -04:00
parent 8534e80af8
commit 582a2c747d
2 changed files with 159 additions and 134 deletions

View File

@@ -97,6 +97,13 @@ The config file is not provided on the CLI, so it will read the configuration da
from /tmp/openalpr.conf from /tmp/openalpr.conf
.PP .PP
.RS .RS
\f(CW$ alpr -c us *.jpg
.RE
.PP
This command will attempt to recognize number plates in all jpeg images in the current directory
image using the USA\-style recognition data.
.PP
.RS
\f(CW$ alpr \-j /source/video.mp4 \f(CW$ alpr \-j /source/video.mp4
.RE .RE
.PP .PP
@@ -104,13 +111,21 @@ This command reads data from an input video (/source/video.mp4) and outputs
recognition data as JSON. recognition data as JSON.
.PP .PP
.RS .RS
\f(CW$ alpr \-j < /source/imagefilelist.txt > /out/recognitionresults.txt \f(CW$ alpr \-j stdin < /source/imagefilelist.txt > /out/recognitionresults.txt
.RE .RE
.PP .PP
This command processes a list of image files provided in /source/imagefilelist.txt This command processes a list of image files provided in /source/imagefilelist.txt
and writes JSON results to /out/recognitionresults.txt. and writes JSON results to /out/recognitionresults.txt.
.PP .PP
.RS
\f(CW$ alpr webcam
.RE .RE
.PP
This command processes video from your webcam. You can also use /dev/video0, /dev/video1, etc.
if you have multiple webcams.
.PP
.RE
.SH "DIAGNOSTICS" .SH "DIAGNOSTICS"

View File

@@ -56,7 +56,7 @@ bool program_active = true;
int main( int argc, const char** argv ) int main( int argc, const char** argv )
{ {
std::string filename; std::vector<std::string> filenames;
std::string configFile = ""; std::string configFile = "";
bool outputJson = false; bool outputJson = false;
int seektoms = 0; int seektoms = 0;
@@ -66,7 +66,7 @@ int main( int argc, const char** argv )
TCLAP::CmdLine cmd("OpenAlpr Command Line Utility", ' ', Alpr::getVersion()); TCLAP::CmdLine cmd("OpenAlpr Command Line Utility", ' ', Alpr::getVersion());
TCLAP::UnlabeledValueArg<std::string> fileArg( "image_file", "Image containing license plates", false, "", "image_file_path" ); TCLAP::UnlabeledMultiArg<std::string> fileArg( "image_file", "Image containing license plates", true, "", "image_file_path" );
TCLAP::ValueArg<std::string> countryCodeArg("c","country","Country code to identify (either us for USA or eu for Europe). Default=us",false, "us" ,"country_code"); TCLAP::ValueArg<std::string> countryCodeArg("c","country","Country code to identify (either us for USA or eu for Europe). Default=us",false, "us" ,"country_code");
@@ -96,7 +96,7 @@ int main( int argc, const char** argv )
return 1; return 1;
} }
filename = fileArg.getValue(); filenames = fileArg.getValue();
country = countryCodeArg.getValue(); country = countryCodeArg.getValue();
seektoms = seekToMsArg.getValue(); seektoms = seekToMsArg.getValue();
@@ -132,7 +132,11 @@ int main( int argc, const char** argv )
return 1; return 1;
} }
if (filename.empty()) for (unsigned int i = 0; i < filenames.size(); i++)
{
std::string filename = filenames[i];
if (filename == "stdin")
{ {
std::string filename; std::string filename;
while (std::getline(std::cin, filename)) while (std::getline(std::cin, filename))
@@ -161,7 +165,8 @@ int main( int argc, const char** argv )
while (cap.read(frame)) while (cap.read(frame))
{ {
if (framenum == 0) motiondetector.ResetMotionDetection(&frame); if (framenum == 0)
motiondetector.ResetMotionDetection(&frame);
detectandshow(&alpr, frame, "", outputJson); detectandshow(&alpr, frame, "", outputJson);
sleep_ms(10); sleep_ms(10);
framenum++; framenum++;
@@ -184,7 +189,8 @@ int main( int argc, const char** argv )
if (response != -1) if (response != -1)
{ {
if (framenum == 0) motiondetector.ResetMotionDetection(&latestFrame); if (framenum == 0)
motiondetector.ResetMotionDetection(&latestFrame);
detectandshow(&alpr, latestFrame, "", outputJson); detectandshow(&alpr, latestFrame, "", outputJson);
} }
@@ -197,8 +203,10 @@ int main( int argc, const char** argv )
std::cout << "Video processing ended" << std::endl; std::cout << "Video processing ended" << std::endl;
} }
else if (hasEndingInsensitive(filename, ".avi") || hasEndingInsensitive(filename, ".mp4") || hasEndingInsensitive(filename, ".webm") || else if (hasEndingInsensitive(filename, ".avi") || hasEndingInsensitive(filename, ".mp4") ||
hasEndingInsensitive(filename, ".flv") || hasEndingInsensitive(filename, ".mjpg") || hasEndingInsensitive(filename, ".mjpeg") || hasEndingInsensitive(filename, ".webm") ||
hasEndingInsensitive(filename, ".flv") || hasEndingInsensitive(filename, ".mjpg") ||
hasEndingInsensitive(filename, ".mjpeg") ||
hasEndingInsensitive(filename, ".mkv") hasEndingInsensitive(filename, ".mkv")
) )
{ {
@@ -217,7 +225,8 @@ int main( int argc, const char** argv )
cv::imwrite(LAST_VIDEO_STILL_LOCATION, frame); cv::imwrite(LAST_VIDEO_STILL_LOCATION, frame);
} }
std::cout << "Frame: " << framenum << std::endl; std::cout << "Frame: " << framenum << std::endl;
if (framenum == 0) motiondetector.ResetMotionDetection(&frame); if (framenum == 0)
motiondetector.ResetMotionDetection(&frame);
detectandshow(&alpr, frame, "", outputJson); detectandshow(&alpr, frame, "", outputJson);
//create a 1ms delay //create a 1ms delay
sleep_ms(1); sleep_ms(1);
@@ -274,6 +283,7 @@ int main( int argc, const char** argv )
std::cerr << "Unknown file type" << std::endl; std::cerr << "Unknown file type" << std::endl;
return 1; return 1;
} }
}
return 0; return 0;
} }