diff --git a/README.md b/README.md index cdc0be2..48e60ec 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,7 @@ The subject is available here: [Test Algo](./test_algo.pdf) -## TODO -- [ ] document -- [X] dumb packing -- [ ] skyline -- [X] add raygui -- [X] resize box -- [X] delete box in gui by clicking -- [ ] wrap stb_rect_pack? -- [X] change bbox api to origin + size -- [X] dummy A2 -- [X] package - -## Installation - -## Notes - -### Question 1 +## Question 1 > As a preprocessing step of a second algorithm A2, we would like to combine all > the regions corresponding to the bounding boxes into a new image FRegions of @@ -32,10 +16,13 @@ I looked up some solutions online and found a great article by David Colson: "[Exploring rectangle packing algorithms][2]". It gives a lot a references and compares different algorithms. -I decided at first to implement his naive "row packer" to quickly have an -implementation and try it out. +I decided to implement his naive "row packer" to quickly have an implementation +and try it out. -### Question 2 +If I were to implement a more robust algorithm, I would choose the [Skyline][3] +approach. It looks likes a good trade-off of quality and performance. + +## Question 2 > A2 then takes as input F Regions and outputs new bounding boxes B′. We would > like now to compute the location of each of these new bounding boxes in F @@ -59,7 +46,7 @@ recompute them by looking at pixel similarity between F and FRegions but it would be costly, and a bit wasteful since we already computed the bounding boxes. -### Question 3 +## Question 3 > We would like now to be able to provide to the algorithm A2 either the > region-based image or the initial image without transformation, which @@ -72,10 +59,12 @@ support for a binary mask. In the same way A2 is suppose to ignore zeros valud in the region-based frame, it could be modified to ignore areas in an image where the mask is set to zero. -## GUI +## Installation + +### GUI In order to easily debug and better visualize the problem, I chose to implement -a minimal GUI using [raylib][3]. +a minimal GUI using [raylib][4]. You can build it with `./build-gui.sh` (you need to installed [raylib required libraries](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)). @@ -83,7 +72,7 @@ libraries](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)). You can add, move, and resize boxes. Processing steps are triggered with buttons. -## CLI +### CLI A commandline sample is also available, in case the raylib library cannot be built, or if we need to benchmark performance. @@ -113,4 +102,5 @@ To avoid name collision, I created my own namespace `freling`. [1]: https://en.wikipedia.org/wiki/Packing_problems#Packing_of_rectangles [2]: https://www.david-colson.com/2020/03/10/exploring-rect-packing.html -[3]: https://github.com/raysan5/raylib +[3]: https://www.researchgate.net/publication/221049934_A_Skyline-Based_Heuristic_for_the_2D_Rectangular_Strip_Packing_Problem +[4]: https://github.com/raysan5/raylib diff --git a/src/pack.cpp b/src/pack.cpp index 9b922ea..c328919 100644 --- a/src/pack.cpp +++ b/src/pack.cpp @@ -28,6 +28,9 @@ void blit(const Frame& in_frame, } } +// This packer is based on the "row packing" approach as described by David +// Colson in his article: +// https://www.david-colson.com/2020/03/10/exploring-rect-packing.html std::optional pack(const Frame& in_frame, const std::vector& bboxes, std::vector& packed_bboxes) {