From e4ec24000b7ed45490eaa988c94546f480114933 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 17 Aug 2021 16:29:44 -0400 Subject: Finished rectangle annotation code --- .gitignore | 1 + src/labeller.cc | 23 +++++++++++++++++++---- src/labeller.h | 3 +++ src/playback.cc | 4 ++-- src/ui.cc | 22 +++++++++++++--------- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 6443e30..724c6b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ annotator *.o +saves/ 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 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