aboutsummaryrefslogtreecommitdiff
path: root/src/labeller.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-08-17 16:29:44 -0400
committerYour Name <you@example.com>2021-08-17 16:29:44 -0400
commite4ec24000b7ed45490eaa988c94546f480114933 (patch)
treeed8a9bb992c2ffc3e49fdec2abd478d1c07f90e2 /src/labeller.cc
parentab5e941dcaedcf2cc896eed1ea257c59780fdb59 (diff)
downloadannotator-e4ec24000b7ed45490eaa988c94546f480114933.tar.gz
annotator-e4ec24000b7ed45490eaa988c94546f480114933.tar.bz2
annotator-e4ec24000b7ed45490eaa988c94546f480114933.zip
Finished rectangle annotation code
Diffstat (limited to 'src/labeller.cc')
-rw-r--r--src/labeller.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/labeller.cc b/src/labeller.cc
index ea72db0..d64ac93 100644
--- a/src/labeller.cc
+++ b/src/labeller.cc
@@ -19,12 +19,27 @@ namespace backend {
std::string line;
const char delim = ',';
while(std::getline(in, line)) {
- std::size_t split = line.find(delim);
- if(split == std::string::npos) {
+ // Fields are label,time,x1,y1,x2,y2
+ std::vector<std::string> parts;
+ std::size_t split;
+ while((split = line.find(delim)) != std::string::npos) {
+ parts.push_back(line.substr(0, split));
+ line = line.substr(split+1);
+ }
+ // And pick up that last part
+ parts.push_back(line);
+ if(parts.size() < 2) {
std::cerr << "Error reading " << savepath << std::endl;
throw std::runtime_error(savepath.string());
}
- data.annotations.push_back(label(line.substr(0, split), std::stod(line.substr(split+1))));
+ label lab(parts[0], std::stod(parts[1]));
+ if(parts.size() == 6) {
+ lab.location.x1 = std::stoi(parts[2]);
+ lab.location.y1 = std::stoi(parts[3]);
+ lab.location.x2 = std::stoi(parts[4]);
+ lab.location.y2 = std::stoi(parts[5]);
+ }
+ data.annotations.push_back(lab);
}
}
@@ -138,7 +153,7 @@ namespace backend {
std::vector<label> a(data->annotations);
std::sort(a.begin(), a.end(), compareLabels);
for(label l : a) {
- out << l.name << "," << l.time << std::endl;
+ out << l.name << "," << l.time << "," << l.location.string() << std::endl;
}
out.close();
}