mirror of
https://github.com/gosticks/openpose.git
synced 2026-10-06 23:26:58 +00:00
Valid image extensions are now case insensitive
This commit is contained in:
@@ -16,6 +16,10 @@ namespace op
|
||||
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::string toLower(const std::string& string);
|
||||
|
||||
OP_API std::string toUpper(const std::string& string);
|
||||
}
|
||||
|
||||
#endif // OPENPOSE_UTILITIES_STRING_HPP
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace op
|
||||
try
|
||||
{
|
||||
// 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
|
||||
".jpg", "jpeg", ".png"}; // Most of them 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
|
||||
const auto imagePaths = getFilesOnDirectory(imageDirectoryPath, extensions);
|
||||
|
||||
// Check #files > 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <openpose/utilities/fileSystem.hpp>
|
||||
#include <openpose/utilities/string.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <algorithm> // std::transform
|
||||
#include <openpose/utilities/string.hpp>
|
||||
|
||||
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<char>(const char number, const unsigned long long stringLength);
|
||||
|
||||
Reference in New Issue
Block a user