Skip to content

Commit a10d4e8

Browse files
Valid image extensions are now case insensitive
1 parent 14c829b commit a10d4e8

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

include/openpose/utilities/string.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ namespace op
1616
OP_API std::string toFixedLengthString(const T number, const unsigned long long stringLength = 0);
1717

1818
OP_API std::vector<std::string> splitString(const std::string& stringToSplit, const std::string& delimiter);
19+
20+
OP_API std::string toLower(const std::string& string);
21+
22+
OP_API std::string toUpper(const std::string& string);
1923
}
2024

2125
#endif // OPENPOSE_UTILITIES_STRING_HPP

src/openpose/producer/imageDirectoryReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace op
1010
try
1111
{
1212
// Get files on directory with the desired extensions
13-
const std::vector<std::string> extensions{".bmp", ".dib", ".pbm", ".pgm", ".ppm", ".sr", ".ras", // Completely supported by OpenCV
14-
".jpg", "jpeg", ".png"}; // Most of them supported by OpenCV
13+
const std::vector<std::string> extensions{"bmp", "dib", "pbm", "pgm", "ppm", "sr", "ras", // Completely supported by OpenCV
14+
"jpg", "jpeg", "png"}; // Most of them supported by OpenCV
1515
const auto imagePaths = getFilesOnDirectory(imageDirectoryPath, extensions);
1616

1717
// Check #files > 0

src/openpose/utilities/fileSystem.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <boost/filesystem.hpp>
22
#include <boost/range/iterator_range_core.hpp>
33
#include <openpose/utilities/fileSystem.hpp>
4+
#include <openpose/utilities/string.hpp>
45

56
namespace op
67
{
@@ -134,9 +135,9 @@ namespace op
134135
{
135136
try
136137
{
137-
const auto cleanedExtension = removeExtensionDot(extension);
138+
const auto cleanedExtension = toLower(removeExtensionDot(extension));
138139
for (auto& extensionI : extensions)
139-
if (cleanedExtension == removeExtensionDot(extensionI))
140+
if (cleanedExtension == toLower(removeExtensionDot(extensionI)))
140141
return true;
141142
return false;
142143
}

src/openpose/utilities/string.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <algorithm> // std::transform
12
#include <openpose/utilities/string.hpp>
23

34
namespace op
@@ -55,6 +56,36 @@ namespace op
5556
}
5657
}
5758

59+
std::string toLower(const std::string& string)
60+
{
61+
try
62+
{
63+
auto result = string;
64+
std::transform(string.begin(), string.end(), result.begin(), tolower);
65+
return result;
66+
}
67+
catch (const std::exception& e)
68+
{
69+
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
70+
return "";
71+
}
72+
}
73+
74+
std::string toUpper(const std::string& string)
75+
{
76+
try
77+
{
78+
auto result = string;
79+
std::transform(string.begin(), string.end(), result.begin(), toupper);
80+
return result;
81+
}
82+
catch (const std::exception& e)
83+
{
84+
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
85+
return "";
86+
}
87+
}
88+
5889

5990
// Signed
6091
template std::string toFixedLengthString<char>(const char number, const unsigned long long stringLength);

0 commit comments

Comments
 (0)