mirror of
https://github.com/opencv/opencv.git
synced 2025-01-19 06:53:50 +08:00
samples: replace regex
- GCC 4.8.5 doesn't support regex
This commit is contained in:
parent
22d64ae08f
commit
08bee40fa2
@ -1,6 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
#include <opencv2/imgproc.hpp>
|
#include <opencv2/imgproc.hpp>
|
||||||
#include <opencv2/highgui.hpp>
|
#include <opencv2/highgui.hpp>
|
||||||
@ -24,6 +23,21 @@ std::string keys =
|
|||||||
"{ evalDataPath edp | | Path to benchmarks for evaluation. "
|
"{ evalDataPath edp | | Path to benchmarks for evaluation. "
|
||||||
"Download links are provided in doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown}";
|
"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<std::string>& 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)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
@ -114,9 +128,9 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
gtLine = gtLine.substr(0, splitLoc);
|
gtLine = gtLine.substr(0, splitLoc);
|
||||||
|
|
||||||
std::regex delimiter(",");
|
std::vector<std::string> v;
|
||||||
std::vector<String> v(std::sregex_token_iterator(gtLine.begin(), gtLine.end(), delimiter, -1),
|
split(gtLine, ',', v);
|
||||||
std::sregex_token_iterator());
|
|
||||||
std::vector<int> loc;
|
std::vector<int> loc;
|
||||||
std::vector<Point> pts;
|
std::vector<Point> pts;
|
||||||
for (auto && s : v) {
|
for (auto && s : v) {
|
||||||
|
Loading…
Reference in New Issue
Block a user