#include #include #include #include "bounding_box.h" #include "pack.h" #include "png.h" namespace fs = std::filesystem; int main(int argc, const char* argv[]) { // We take an image path and a list of points (grouped by 4 to define // bounding boxes). if (argc < 6 or (argc - 2) % 4 != 0) { std::cerr << "Usage: " << argv[0] << " path/to/image" << " x1 y1 x2 y2 [...]\n" << "x/y points must be grouped by 4 to define bounding boxes\n"; return 1; } const fs::path input(argv[1]); if (!fs::exists(input)) { std::cerr << "Input file " << input << " does not exist.\n"; return 1; } const std::optional in_frame = load_png(input); if (!in_frame) { std::cerr << "Cannot load file " << input << "\n"; return 1; } int i = 2; std::vector 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(freling::BoundingBox({x1, y1, x2, y2})); i += 4; } std::optional regions = pack(*in_frame, bboxes); return 0; }