aboutsummaryrefslogtreecommitdiff
path: root/src/annotator.cc
blob: c74f04fb4ca8769a01f542f108caaacb93dfb351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "playback.h"
#include "ui.h"
#include "labeller.h"
#include <vector>
#include <iostream>
#include <memory>

// Removes flags from args (in-place) and returns vector of flags
std::vector<std::string> extractFlags(std::vector<std::string>& args) {
    std::vector<std::string> 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<std::string> args(&argv[1], &argv[argc]);
    std::vector<std::string> 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<frontend::playback> 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<backend::labeller> labeller(new backend::labeller(savepath));
    frontend::ui ui(playback, labeller);
    ui.begin();
    return 0;
}