mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-07 00:02:52 +08:00
Case insensitive file match for alpr (matches .jpg and .JPEG)
This commit is contained in:
@@ -197,8 +197,8 @@ int main( int argc, const char** argv )
|
||||
|
||||
std::cout << "Video processing ended" << std::endl;
|
||||
}
|
||||
else if (hasEnding(filename, ".avi") || hasEnding(filename, ".mp4") || hasEnding(filename, ".webm") ||
|
||||
hasEnding(filename, ".flv") || hasEnding(filename, ".mjpg") || hasEnding(filename, ".mjpeg"))
|
||||
else if (hasEndingInsensitive(filename, ".avi") || hasEndingInsensitive(filename, ".mp4") || hasEndingInsensitive(filename, ".webm") ||
|
||||
hasEndingInsensitive(filename, ".flv") || hasEndingInsensitive(filename, ".mjpg") || hasEndingInsensitive(filename, ".mjpeg"))
|
||||
{
|
||||
if (fileExists(filename.c_str()))
|
||||
{
|
||||
@@ -227,7 +227,8 @@ int main( int argc, const char** argv )
|
||||
std::cerr << "Video file not found: " << filename << std::endl;
|
||||
}
|
||||
}
|
||||
else if (hasEnding(filename, ".png") || hasEnding(filename, ".jpg") || hasEnding(filename, ".gif"))
|
||||
else if (hasEndingInsensitive(filename, ".png") || hasEndingInsensitive(filename, ".jpg") ||
|
||||
hasEndingInsensitive(filename, ".jpeg") || hasEndingInsensitive(filename, ".gif"))
|
||||
{
|
||||
if (fileExists(filename.c_str()))
|
||||
{
|
||||
@@ -248,7 +249,7 @@ int main( int argc, const char** argv )
|
||||
|
||||
for (int i = 0; i< files.size(); i++)
|
||||
{
|
||||
if (hasEnding(files[i], ".jpg") || hasEnding(files[i], ".png"))
|
||||
if (hasEndingInsensitive(files[i], ".jpg") || hasEndingInsensitive(files[i], ".png"))
|
||||
{
|
||||
std::string fullpath = filename + "/" + files[i];
|
||||
std::cout << fullpath << std::endl;
|
||||
|
@@ -21,6 +21,19 @@ bool hasEnding (std::string const &fullString, std::string const &ending)
|
||||
}
|
||||
}
|
||||
|
||||
bool hasEndingInsensitive(const std::string& fullString, const std::string& ending)
|
||||
{
|
||||
if (fullString.length() < ending.length())
|
||||
return false;
|
||||
|
||||
int startidx = fullString.length() - ending.length();
|
||||
|
||||
for (unsigned int i = startidx; i < fullString.length(); ++i)
|
||||
if (tolower(fullString[i]) != tolower(ending[i - startidx]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DirectoryExists( const char* pzPath )
|
||||
{
|
||||
if ( pzPath == NULL) return false;
|
||||
|
@@ -19,6 +19,8 @@
|
||||
|
||||
bool startsWith(std::string const &fullString, std::string const &prefix);
|
||||
bool hasEnding (std::string const &fullString, std::string const &ending);
|
||||
bool hasEndingInsensitive(const std::string& fullString, const std::string& ending);
|
||||
|
||||
bool DirectoryExists( const char* pzPath );
|
||||
bool fileExists( const char* pzPath );
|
||||
std::vector<std::string> getFilesInDir(const char* dirPath);
|
||||
|
Reference in New Issue
Block a user