Tiling Zipping Printing
Too long;didn't read
We did the "tiling" of the projection for printing on small sheets of paper.
Go see the video below and try it yourself here corner.builders !
Where we are
As always, I invite you to go back to the previous editions of this newsletter if you want more context or more details of the advancements! Last time we finished with being able to project an image in a rectangular room, a good starting point!
Goal of this session
The next step is to be able to "extract" printable images from the projected image, and maybe try a first print!
The approach
The first dumb and simple approach to try, is what we could call brute-force. Generate all possible camera positions on a grid on each wall, and take "pictures" in a loop. If the picture has pixels different than the color of the wall, then there is a part of projection of interest and add the image in a zip archive. At the end, "download" the archive. The zip file will contain all images ready to print.
Camera placement
The cameras should get non-overlapping pictures of the room. As we just need image without a sense of perspective we can use orthographic projection (imaging all photons emitting in parallel and hitting a flat surface).
Image size
The physical size of the image depends on the size of the paper we intend to print on. We should later have a UI parameter for this, like selecting A4, A3, or custom size. For now the size is A3.
Layout
Even though we intent to print of a A3 sheet of paper, the image itself shall be smaller to allow some margin and be cut after to fit. We need to prepare a rectangle to print outside the area to show where to cut.
Here is a printed image to show how that looks
Here the black border is not necessary (and almost invisible), but in a area with a lot of white, it helps :).
Image names
Even if it would not be the hardest puzzle to solve, we name each image with the name of the wall surface if is projected on (like Left, Ceiling, etc) and the row/column number of the position in the surface grid, like Front_row_4_col_3.png.
Later we could also print the name in the back of the image, if necessary.
Rust iterators
On the rust side of things, the loop pipeline
wall surface->row/col->camera->pixels->png->zip is made quite easy and efficient and expressive with the use of the rust iterators. I might talk about them in another newsletter editions !
领英推荐
Some useful crates
The image crate to convert a Vec<u8> into a png.
The async-zip crate. This one was tricky. I first started with the zip crate but it is not (yet) compatible with the WASM compilation target. Luckily async-zip is.
poll_promise to make use of the async functions of async-zip in the non-async trunk wasm context.
Room edges
A lot of rooms are of uniform wall colors (often white). To make the junction between walls easily noticeable, I added the room edges.
User journey
Here is a video of the process of generating and checking the image from my mobile. On mobile the virtual keyboard doesn't show up to enter precise values for the slider (fixable, but not now). I added some button for more precise control.
Testing
Let's do a first print test!
Printing shenanigans
As printing size is crucial for our application, the density of pixels should be correlated of the one of the printer. If i make the assumption to have 100 pixels in 1 inch, then printing 100 pixels should really take 1 inch. However I couldn't find the DPI setting in the available printer. Only vague stuff like "fit to size", passeport, etc. Still I really wanted to try so I went ahead and printed. However, not all my images are the same size between walls, and the automatic resizing messed up a bit the relative proportion. Maybe PNG is not the right choice and PDF would be more size-immutable?
Assembling
As the printing was not perfect I didn't want to spend too much time on impossible alignment but still went ahead to check what other problems we might have. For an easier and nicer finishing, I will put the image on a hard surface next time, and I think it will be quite easy to install.
Here you can see a quick glimpse!
What's next
Try reprinting with correct size for near perfect final product!
On the software side: support 3d spherical images. My next cool use-case would be to do bathroom tiles that goes around, like in a shower. I would need a 3d image to wrap around.
This also means that we need a way to specify custom tiling.
See you next!
Aspiring Software Team Lead - Robotics Software Developer Rust/C++
1 年What we could improve: making a progress bar for the zipping process as the user currently doesn't know if the app crashed or something else. Make better buttons ??♂? , letting the user chose their own images, etc, etc! what else?