add bounding box

This commit is contained in:
Fabien Freling 2022-02-12 00:28:54 +01:00
parent 2e24f0314b
commit 7c383dc245
12 changed files with 153 additions and 4 deletions

View file

@ -1,5 +1,10 @@
#include <filesystem>
#include <iostream>
#include <vector>
#include "bounding_box.h"
#include "pack.h"
#include "png.h"
namespace fs = std::filesystem;
@ -20,5 +25,25 @@ int main(int argc, const char* argv[]) {
return 1;
}
const std::optional<Frame> in_frame = load_png(input);
if (!in_frame) {
std::cerr << "Cannot load file " << input << "\n";
return 1;
}
int i = 2;
std::vector<BoundingBox> bboxes;
bboxes.reserve((argc - 2) / 4);
while (i < argc) {
const uint32_t x1 = atoi(argv[i]);
const uint32_t y1 = atoi(argv[i + 1]);
const uint32_t x2 = atoi(argv[i + 2]);
const uint32_t y2 = atoi(argv[i + 3]);
bboxes.push_back(BoundingBox({x1, y1, x2, y2}));
i += 4;
}
Frame regions = pack(*in_frame, bboxes);
return 0;
}