Basic stereophoto with raspistill

Other software discussion
Post Reply
stereomaton
Posts: 215
Joined: Tue May 21, 2019 12:33 pm
Location: France

Basic stereophoto with raspistill

Post by stereomaton »

Here is how to shoot a basic stereophoto from the command line.
Because it was not so obvious, I share the way I just found.

Note that no other programs should control the video bus, thus you might need to stop the autostarting stereopi software suite [for example by stopping everything started in rc.local with "systemctl stop rc-local.service"]

The magic spell is:

Code: Select all

raspistill -n -t 1 -3d sbs -dec -vf -hf -w 5184 -h 1944 -o image.jpg
EDIT: please remove the -dec option for better results (rational later)

-n disable preview [I do not have screen plugged, so I do not know what it is]
-t 1 delays shot by 1ms [without this precision, the default is 5s. Less or equal to zero does not seem to work]
-3d sbs side-by-side output desired
-dec labeled "Half width/height of stereo image", it is necessary to not have the image overly cropped [at least before I added explicit width] EDIT: with image size specified, using this option cause the image to have wrong proportions
-vf -hf flip image vertically and horizontally [My cameras have the white ribbon up]
-w 5184 -h 1944 specify size to get full size images side by side [seems that -dec might be optional in this specific case EDIT: Yes, you better not want to use -dec with size]
-o image.jpg specify image output name

With this command, I get a side-by-side parallel stereo pair.
Man can use it directly on cardboard or other stereoscopic viewer, but it would be better to postprocess, in particular by doing alignment and stereo window placement, for more enjoyable viewing experience.

To avoid changing the command at every shot, man can replace "image.jpg" by "$(date +%Y%m%d_%H%M%S_%N.jpg)" and write it to a script. This ugly riddle creates a file name based on system date (including nanosec) so that a new file is created at each time [except if you go back in time, and thus the probability to overwrite is quite low anyway].

If man wants to use this method (actually writing a specialized program might be a good idea), man can use imagemagick to separate the two views man just got.

Code: Select all

convert -crop 50%x100% 20190521_154521_447899386.jpg im%d.jpg
20190521_154521_447899386.jpg is the side-by-side image, im0.jpg and im1.jpg are the two synced images separated so that they can be sent to other software to create well processed awesome stereophoto.
Last edited by stereomaton on Sat Aug 10, 2019 6:15 pm, edited 2 times in total.
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi (v1) Standard Edition + CM3Lite module + a few cameras

User avatar
Realizator
Site Admin
Posts: 900
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: Basic stereophoto with raspistill

Post by Realizator »

Stetreomaton, thank you for your code and usage example!
One more tip. Sometimes you need to swap left and right images. There are two approaches.
1. Do horisontal flip (use -hf key). Actually raspistill will flip each image, but not stereopair. It's a little puzzle to your brain, but in this case you will obtain swapped images and flipped stereoscopic image.
2. Use "-3dswap" key. But... it does not work now (not implemented yet), look at my discussion with Pi engineers here. But you CAN do the swap. Just add "-cs 1" key to raspistill. Actually in stereoscopic mode one camera is a master (number 0), and another one is a slave (number 1). Slave always copy all settings from master, and also image from "slave" goes as a second in a capture process. So if you add "-cs 1" you define second camera as a master, and image capture sequence will be changed.
Eugene a.k.a. Realizator

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

Re: Basic stereophoto with raspistill

Post by stereomaton »

Nice.
I saw that the -3dswap option does not work, but it was not a big deal for me as I prefer the 'parallel' side-by-side format.
The use of "-cs 1" is a clever trick I would not have thought of.
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi (v1) Standard Edition + CM3Lite module + a few cameras

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

Re: Basic stereophoto with raspistill

Post by stereomaton »

Erratum: I just noticed today that decimate option in conjunction with height/width specification is a bad idea as the full view if not used and moreover the aspect ratio is odd. Just remove the -dec option and it would be OK.
I will edit the original post to reflect this observation.
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi (v1) Standard Edition + CM3Lite module + a few cameras

Post Reply