From 5a6248518654ec97d95d2c463e3ffb4be7bbf456 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 13 May 2021 17:20:26 -0400 Subject: Initial commit --- src/annotator.cc | 45 +++++++++++++++++++++ src/labeller.cc | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/labeller.h | 32 +++++++++++++++ src/playback.cc | 69 +++++++++++++++++++++++++++++++++ src/playback.h | 23 +++++++++++ src/settings.cc | 28 ++++++++++++++ src/settings.h | 7 ++++ src/ui.cc | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ui.h | 19 +++++++++ 9 files changed, 454 insertions(+) create mode 100644 src/annotator.cc create mode 100644 src/labeller.cc create mode 100644 src/labeller.h create mode 100644 src/playback.cc create mode 100644 src/playback.h create mode 100644 src/settings.cc create mode 100644 src/settings.h create mode 100644 src/ui.cc create mode 100644 src/ui.h (limited to 'src') diff --git a/src/annotator.cc b/src/annotator.cc new file mode 100644 index 0000000..c74f04f --- /dev/null +++ b/src/annotator.cc @@ -0,0 +1,45 @@ +#include "playback.h" +#include "ui.h" +#include "labeller.h" +#include +#include +#include + +// Removes flags from args (in-place) and returns vector of flags +std::vector extractFlags(std::vector& args) { + std::vector ret; + auto it = args.begin(); + while(it != args.end()) { + if((*it)[0] == '-') { + while((*it)[0] == '-') { + (*it).erase((*it).begin()); + } + ret.push_back(*it); + args.erase(it); + } else { + it++; + } + } + return ret; +} + +int main(int argc, char *argv[]) { + std::string exename = argv[0]; + std::vector args(&argv[1], &argv[argc]); + std::vector flags = extractFlags(args); + if(args.empty()) { + std::cout << "Must provide a path to a video to process!" << std::endl; + } + std::cout << "Loading video " << args[0] << std::endl; + std::filesystem::path p(args[0]); + std::shared_ptr playback(new frontend::playback(p)); + // Format save path + auto savedir = std::filesystem::path("save") / p.parent_path().filename(); + std::filesystem::create_directories(savedir); + auto savepath = savedir / (p.stem().string() + ".txt"); + std::cout << "Saves are written to: " << savepath << std::endl; + std::shared_ptr labeller(new backend::labeller(savepath)); + frontend::ui ui(playback, labeller); + ui.begin(); + return 0; +} diff --git a/src/labeller.cc b/src/labeller.cc new file mode 100644 index 0000000..64da2d7 --- /dev/null +++ b/src/labeller.cc @@ -0,0 +1,116 @@ +#include "labeller.h" +#include "settings.h" +#include + + +namespace backend { + struct labeller_impl { + std::vector labels; + std::vector