This commit is contained in:
Fabien Freling 2022-02-17 23:15:45 +01:00
parent 4447cd67d1
commit 5b32c517c1
12 changed files with 179 additions and 16 deletions

View file

@ -2,7 +2,10 @@
#include <iostream>
#include <vector>
#include "a2.h"
#include "bounding_box.h"
#include "mapping.h"
#include "mask.h"
#include "pack.h"
#include "png.h"
@ -25,7 +28,7 @@ int main(int argc, const char* argv[]) {
return 1;
}
const std::optional<Frame> in_frame = load_png(input);
const std::optional<freling::Frame> in_frame = freling::load_png(input);
if (!in_frame) {
std::cerr << "Cannot load file " << input << "\n";
return 1;
@ -42,9 +45,24 @@ int main(int argc, const char* argv[]) {
bboxes.push_back(freling::BoundingBox({x, y, w, h}));
i += 4;
}
freling::Mask in_mask(in_frame->width, in_frame->height);
std::vector<freling::BoundingBox> packed_bboxes;
std::optional<Frame> regions = pack(*in_frame, bboxes, packed_bboxes);
std::optional<freling::Frame> regions =
pack(*in_frame, bboxes, packed_bboxes);
in_mask.fill(false);
for (const auto& b : bboxes) {
for (int j = b.y; j < b.y + b.height; ++j) {
for (int i = b.x; i < b.x + b.width; ++i) {
in_mask.set(i, j, true);
}
}
};
std::vector<freling::BoundingBox> a2_bboxes = freling::A2(packed_bboxes);
std::vector<freling::BoundingBox> a2_bboxes_origin =
freling::map_to_origin(bboxes, packed_bboxes, a2_bboxes);
return 0;
}