button

StereoPi hardware discussion
Post Reply
henrique_mg
Posts: 15
Joined: Sat Jul 13, 2019 5:10 pm

button

Post by henrique_mg » Tue Aug 27, 2019 7:57 pm

I wanted to put two functions on http: //stereopi.local/
an image alignment button
a button to print the image
can someone help?

stereomaton
Posts: 67
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: button

Post by stereomaton » Fri Aug 30, 2019 6:34 am

I am surprised that Realizator did not already answer to your question, because he is usually very prompt.
Concerning the addition of the buttons in the interface, I did not explore that part yet so I cannot answer.

However, you will need to call a script or a program when the user clicks on the button and I can discuss that part.

Beforehand, I should notice that if you goal were ultimately to print a stereo pair, it would be easier to take the photograph with the stereopi (obviously) and then do all the processing and printing process on a computer. The community of stereophotographs like to use StereoPhoto Maker which works well in wine emulator in case you do not use Windows. It has a lot of tutorials in various languages. Personally, I use the amazing hugin panorama stitcher but it is harder to use at first and almost not documented for this purpose.

The automation of a task is always a little challenging, but that can pay off very quickly when you have to do it repetitively.
I will reply to the two parts in different messages because I think it would be easier to follow.
Last edited by stereomaton on Fri Aug 30, 2019 7:37 am, edited 1 time in total.
Stereophotographer and hacker
StereoPi Standard Edition + CM3Lite module

stereomaton
Posts: 67
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: button

Post by stereomaton » Fri Aug 30, 2019 7:12 am

Concerning the alignment, you have to build a mechanical part to keep the two cameras tied together. The Camera support plates of the kit would do. It is important that the cameras do not move relative to each others because you will calibrate one time, and reapply the found parameters on each photograph afterwards.

The stereopi team provides a tutorial to create depth maps which requires that the two images are aligned. At the end of step 4, before they start to play with depth maps, the script have extracted all the parameters needed to correct the images.
Unfortunately, I did not manage to make it work sufficiently well myself, but I will eventually try again.

In the first prototype of the stereomaton, we used hugin on the stereopi. We first aligned one stereo pair on the PC with hugin and then copied the .pto project file on the board. We had just to cut the image produced by raspistill with imagemagick, place it where the project expected the two images of the other pair, and export directly with nona (the command line part of hugin that is useful in our case). It was slow [1] because it used the CPU but worked pretty well.

In a second version (actually since today), we used opencv warpPerspective method. It is far quicker [2] but does not correct the camera barrel distortion. However, this distortion is sufficiently small for the brain to ignore it in most situations. The downside is that you have to find the homography matrices which is also a bit challenging. The way we used was to ask pano_trafo (a tool of hugin) to extract projected coordinates from the calibration project of the previous prototype and then used them (corrected by the right translation factor) in findHomography method of opencv to extract the matrices.

Another downside of the automated method is that you are stuck with the stereo window placement you have fixed in the calibration phase. That is why we added a rope on the stereomaton to indicate the zone where nothing has to be to avoid any window violation.

This is the big picture of the way we used to automate the process.

[1] About 40s to process an image in the maximum definition of the V1 camera
[2] About 5s to process an image in the maximum definition of the V1 camera
Stereophotographer and hacker
StereoPi Standard Edition + CM3Lite module

stereomaton
Posts: 67
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: button

Post by stereomaton » Fri Aug 30, 2019 7:30 am

For the print part, I did not test anything like that. However, I can provide some keywords for your researches.

The way to go is probably to use the cups program (Common Unix Printing System). It has a web interface to configure the printers and there are some command line interfaces for your program to launch the print (see https://www.cups.org/doc/options.html).

If your printer supports network raw/pdl protocol, you can also create a postscript file and send it to the printer directly.

And of course, the easiest way is still to retrieve the photos on your PC and print them from there.
Stereophotographer and hacker
StereoPi Standard Edition + CM3Lite module

henrique_mg
Posts: 15
Joined: Sat Jul 13, 2019 5:10 pm

Re: button

Post by henrique_mg » Wed Sep 04, 2019 5:26 pm

stereomaton wrote:
Fri Aug 30, 2019 6:34 am
I am surprised that Realizator did not already answer to your question, because he is usually very prompt.
Concerning the addition of the buttons in the interface, I did not explore that part yet so I cannot answer.

However, you will need to call a script or a program when the user clicks on the button and I can discuss that part.

Beforehand, I should notice that if you goal were ultimately to print a stereo pair, it would be easier to take the photograph with the stereopi (obviously) and then do all the processing and printing process on a computer. The community of stereophotographs like to use StereoPhoto Maker which works well in wine emulator in case you do not use Windows. It has a lot of tutorials in various languages. Personally, I use the amazing hugin panorama stitcher but it is harder to use at first and almost not documented for this purpose.

The automation of a task is always a little challenging, but that can pay off very quickly when you have to do it repetitively.
I will reply to the two parts in different messages because I think it would be easier to follow.
First, thank you very much for your attention.
My idea is to set up a photo booth for self-service user, so it would have to be as automatic as possible.
Using the computer and stareomaker manually I already did but would have to be self service

stereomaton
Posts: 67
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: button

Post by stereomaton » Thu Sep 05, 2019 1:33 am

Then you go for the hard way ;)

I already gave an overview of the architecture we use. It is probably not the best solution because we had to make it work before a hard short deadline. As I said, I think that starting from the disparity map tutorial would be a good (probably better) way.

In addition, as every projet we do, the source code (as well as some related conception documents) is public in our GitHub organization space. You can possibly inspire yourself from it, but it is not a beautiful script because everything is very interdependant and there are several hardcoded values which depend on our specific prototype. Again, the chosen solution might not be the best one as already exposed.

We plan to enhance the code to add some features and make it less ugly, but it is a long term goal as the main event which powered the initial project is over. However it motivated a few other members of the hackerspace to buy a StereoPi and it could give a second impulsion.
Stereophotographer and hacker
StereoPi Standard Edition + CM3Lite module

Post Reply