diff --git a/samples/dnn/scene_text_detection.cpp b/samples/dnn/scene_text_detection.cpp index 5b8626caad..156529937a 100644 --- a/samples/dnn/scene_text_detection.cpp +++ b/samples/dnn/scene_text_detection.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -24,6 +23,21 @@ std::string keys = "{ evalDataPath edp | | Path to benchmarks for evaluation. " "Download links are provided in doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown}"; +static +void split(const std::string& s, char delimiter, std::vector& elems) +{ + elems.clear(); + size_t prev_pos = 0; + size_t pos = 0; + while ((pos = s.find(delimiter, prev_pos)) != std::string::npos) + { + elems.emplace_back(s.substr(prev_pos, pos - prev_pos)); + prev_pos = pos + 1; + } + if (prev_pos < s.size()) + elems.emplace_back(s.substr(prev_pos, s.size() - prev_pos)); +} + int main(int argc, char** argv) { // Parse arguments @@ -114,9 +128,9 @@ int main(int argc, char** argv) } gtLine = gtLine.substr(0, splitLoc); - std::regex delimiter(","); - std::vector v(std::sregex_token_iterator(gtLine.begin(), gtLine.end(), delimiter, -1), - std::sregex_token_iterator()); + std::vector v; + split(gtLine, ',', v); + std::vector loc; std::vector pts; for (auto && s : v) {