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 --- src/labeller.cc | 23 +++++++++++++++++++---- src/labeller.h | 3 +++ src/playback.cc | 4 ++-- src/ui.cc | 22 +++++++++++++--------- 4 files changed, 37 insertions(+), 15 deletions(-) (limited to 'src') 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