diff --git a/include/openpose/utilities/string.hpp b/include/openpose/utilities/string.hpp index 596329cc..16df3134 100644 --- a/include/openpose/utilities/string.hpp +++ b/include/openpose/utilities/string.hpp @@ -16,6 +16,10 @@ namespace op OP_API std::string toFixedLengthString(const T number, const unsigned long long stringLength = 0); OP_API std::vector splitString(const std::string& stringToSplit, const std::string& delimiter); + + OP_API std::string toLower(const std::string& string); + + OP_API std::string toUpper(const std::string& string); } #endif // OPENPOSE_UTILITIES_STRING_HPP diff --git a/src/openpose/producer/imageDirectoryReader.cpp b/src/openpose/producer/imageDirectoryReader.cpp index bf5cd5ff..12df26f4 100644 --- a/src/openpose/producer/imageDirectoryReader.cpp +++ b/src/openpose/producer/imageDirectoryReader.cpp @@ -10,8 +10,8 @@ namespace op try { // Get files on directory with the desired extensions - const std::vector extensions{".bmp", ".dib", ".pbm", ".pgm", ".ppm", ".sr", ".ras", // Completely supported by OpenCV - ".jpg", "jpeg", ".png"}; // Most of them supported by OpenCV + const std::vector extensions{"bmp", "dib", "pbm", "pgm", "ppm", "sr", "ras", // Completely supported by OpenCV + "jpg", "jpeg", "png"}; // Most of them supported by OpenCV const auto imagePaths = getFilesOnDirectory(imageDirectoryPath, extensions); // Check #files > 0 diff --git a/src/openpose/utilities/fileSystem.cpp b/src/openpose/utilities/fileSystem.cpp index 3cc87f5f..67a02ba3 100644 --- a/src/openpose/utilities/fileSystem.cpp +++ b/src/openpose/utilities/fileSystem.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace op { @@ -134,9 +135,9 @@ namespace op { try { - const auto cleanedExtension = removeExtensionDot(extension); + const auto cleanedExtension = toLower(removeExtensionDot(extension)); for (auto& extensionI : extensions) - if (cleanedExtension == removeExtensionDot(extensionI)) + if (cleanedExtension == toLower(removeExtensionDot(extensionI))) return true; return false; } diff --git a/src/openpose/utilities/string.cpp b/src/openpose/utilities/string.cpp index 31613c2e..a15857b0 100644 --- a/src/openpose/utilities/string.cpp +++ b/src/openpose/utilities/string.cpp @@ -1,3 +1,4 @@ +#include // std::transform #include namespace op @@ -55,6 +56,36 @@ namespace op } } + std::string toLower(const std::string& string) + { + try + { + auto result = string; + std::transform(string.begin(), string.end(), result.begin(), tolower); + return result; + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + return ""; + } + } + + std::string toUpper(const std::string& string) + { + try + { + auto result = string; + std::transform(string.begin(), string.end(), result.begin(), toupper); + return result; + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + return ""; + } + } + // Signed template std::string toFixedLengthString(const char number, const unsigned long long stringLength);