mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 11:26:56 +08:00
Implements issue #187 -- Support wildcards in alpr executable
This commit is contained in:
@@ -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"
|
||||||
|
|
||||||
|
46
src/main.cpp
46
src/main.cpp
@@ -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,15 +132,19 @@ 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))
|
||||||
{
|
{
|
||||||
if (fileExists(filename.c_str()))
|
if (fileExists(filename.c_str()))
|
||||||
{
|
{
|
||||||
frame = cv::imread( filename );
|
frame = cv::imread(filename);
|
||||||
detectandshow( &alpr, frame, "", outputJson);
|
detectandshow(&alpr, frame, "", outputJson);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -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")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -206,7 +214,7 @@ int main( int argc, const char** argv )
|
|||||||
{
|
{
|
||||||
int framenum = 0;
|
int framenum = 0;
|
||||||
|
|
||||||
cv::VideoCapture cap=cv::VideoCapture();
|
cv::VideoCapture cap = cv::VideoCapture();
|
||||||
cap.open(filename);
|
cap.open(filename);
|
||||||
cap.set(CV_CAP_PROP_POS_MSEC, seektoms);
|
cap.set(CV_CAP_PROP_POS_MSEC, seektoms);
|
||||||
|
|
||||||
@@ -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);
|
||||||
@@ -233,9 +242,9 @@ int main( int argc, const char** argv )
|
|||||||
{
|
{
|
||||||
if (fileExists(filename.c_str()))
|
if (fileExists(filename.c_str()))
|
||||||
{
|
{
|
||||||
frame = cv::imread( filename );
|
frame = cv::imread(filename);
|
||||||
|
|
||||||
bool plate_found = detectandshow( &alpr, frame, "", outputJson);
|
bool plate_found = detectandshow(&alpr, frame, "", outputJson);
|
||||||
|
|
||||||
if (!plate_found && !outputJson)
|
if (!plate_found && !outputJson)
|
||||||
std::cout << "No license plates found." << std::endl;
|
std::cout << "No license plates found." << std::endl;
|
||||||
@@ -249,16 +258,16 @@ int main( int argc, const char** argv )
|
|||||||
{
|
{
|
||||||
std::vector<std::string> files = getFilesInDir(filename.c_str());
|
std::vector<std::string> files = getFilesInDir(filename.c_str());
|
||||||
|
|
||||||
std::sort( files.begin(), files.end(), stringCompare );
|
std::sort(files.begin(), files.end(), stringCompare);
|
||||||
|
|
||||||
for (int i = 0; i< files.size(); i++)
|
for (int i = 0; i < files.size(); i++)
|
||||||
{
|
{
|
||||||
if (is_supported_image(files[i]))
|
if (is_supported_image(files[i]))
|
||||||
{
|
{
|
||||||
std::string fullpath = filename + "/" + files[i];
|
std::string fullpath = filename + "/" + files[i];
|
||||||
std::cout << fullpath << std::endl;
|
std::cout << fullpath << std::endl;
|
||||||
frame = cv::imread( fullpath.c_str() );
|
frame = cv::imread(fullpath.c_str());
|
||||||
if (detectandshow( &alpr, frame, "", outputJson))
|
if (detectandshow(&alpr, frame, "", outputJson))
|
||||||
{
|
{
|
||||||
//while ((char) cv::waitKey(50) != 'c') { }
|
//while ((char) cv::waitKey(50) != 'c') { }
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user