Skip to content

Commit 08bee40

Browse files
committed
samples: replace regex
- GCC 4.8.5 doesn't support regex
1 parent 22d64ae commit 08bee40

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

samples/dnn/scene_text_detection.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <iostream>
22
#include <fstream>
3-
#include <regex>
43

54
#include <opencv2/imgproc.hpp>
65
#include <opencv2/highgui.hpp>
@@ -24,6 +23,21 @@ std::string keys =
2423
"{ evalDataPath edp | | Path to benchmarks for evaluation. "
2524
"Download links are provided in doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown}";
2625

26+
static
27+
void split(const std::string& s, char delimiter, std::vector<std::string>& elems)
28+
{
29+
elems.clear();
30+
size_t prev_pos = 0;
31+
size_t pos = 0;
32+
while ((pos = s.find(delimiter, prev_pos)) != std::string::npos)
33+
{
34+
elems.emplace_back(s.substr(prev_pos, pos - prev_pos));
35+
prev_pos = pos + 1;
36+
}
37+
if (prev_pos < s.size())
38+
elems.emplace_back(s.substr(prev_pos, s.size() - prev_pos));
39+
}
40+
2741
int main(int argc, char** argv)
2842
{
2943
// Parse arguments
@@ -114,9 +128,9 @@ int main(int argc, char** argv)
114128
}
115129
gtLine = gtLine.substr(0, splitLoc);
116130

117-
std::regex delimiter(",");
118-
std::vector<String> v(std::sregex_token_iterator(gtLine.begin(), gtLine.end(), delimiter, -1),
119-
std::sregex_token_iterator());
131+
std::vector<std::string> v;
132+
split(gtLine, ',', v);
133+
120134
std::vector<int> loc;
121135
std::vector<Point> pts;
122136
for (auto && s : v) {

0 commit comments

Comments
 (0)