提交 a10d4e8c 编写于 作者: G gineshidalgo99

Valid image extensions are now case insensitive

上级 14c829b5
...@@ -16,6 +16,10 @@ namespace op ...@@ -16,6 +16,10 @@ namespace op
OP_API std::string toFixedLengthString(const T number, const unsigned long long stringLength = 0); OP_API std::string toFixedLengthString(const T number, const unsigned long long stringLength = 0);
OP_API std::vector<std::string> splitString(const std::string& stringToSplit, const std::string& delimiter); OP_API std::vector<std::string> 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 #endif // OPENPOSE_UTILITIES_STRING_HPP
...@@ -10,8 +10,8 @@ namespace op ...@@ -10,8 +10,8 @@ namespace op
try try
{ {
// Get files on directory with the desired extensions // Get files on directory with the desired extensions
const std::vector<std::string> extensions{".bmp", ".dib", ".pbm", ".pgm", ".ppm", ".sr", ".ras", // Completely supported by OpenCV const std::vector<std::string> extensions{"bmp", "dib", "pbm", "pgm", "ppm", "sr", "ras", // Completely supported by OpenCV
".jpg", "jpeg", ".png"}; // Most of them supported by OpenCV "jpg", "jpeg", "png"}; // Most of them supported by OpenCV
const auto imagePaths = getFilesOnDirectory(imageDirectoryPath, extensions); const auto imagePaths = getFilesOnDirectory(imageDirectoryPath, extensions);
// Check #files > 0 // Check #files > 0
......
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/range/iterator_range_core.hpp> #include <boost/range/iterator_range_core.hpp>
#include <openpose/utilities/fileSystem.hpp> #include <openpose/utilities/fileSystem.hpp>
#include <openpose/utilities/string.hpp>
namespace op namespace op
{ {
...@@ -134,9 +135,9 @@ namespace op ...@@ -134,9 +135,9 @@ namespace op
{ {
try try
{ {
const auto cleanedExtension = removeExtensionDot(extension); const auto cleanedExtension = toLower(removeExtensionDot(extension));
for (auto& extensionI : extensions) for (auto& extensionI : extensions)
if (cleanedExtension == removeExtensionDot(extensionI)) if (cleanedExtension == toLower(removeExtensionDot(extensionI)))
return true; return true;
return false; return false;
} }
......
#include <algorithm> // std::transform
#include <openpose/utilities/string.hpp> #include <openpose/utilities/string.hpp>
namespace op namespace op
...@@ -55,6 +56,36 @@ 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 // Signed
template std::string toFixedLengthString<char>(const char number, const unsigned long long stringLength); template std::string toFixedLengthString<char>(const char number, const unsigned long long stringLength);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册