So the initial stereoscopic camera code has just been submitted, and Dom is intending to do a release probably tonight.
This has been slightly rushed through to try and get it into the wild, so please report back if you hit issues, BUT there are restrictions - break the rules at your peril!
There is one new MMAL parameter that is valid on all 3 of the camera output ports - MMAL_PARAMETER_STEREOSCOPIC_MODE. It takes a MMAL_PARAMETER_STEREOSCOPIC_MODE_T
Code: Select all
typedef enum MMAL_STEREOSCOPIC_MODE_T {
MMAL_STEREOSCOPIC_MODE_NONE = 0,
MMAL_STEREOSCOPIC_MODE_SIDE_BY_SIDE = 1,
MMAL_STEREOSCOPIC_MODE_TOP_BOTTOM = 2,
MMAL_STEREOSCOPIC_MODE_MAX = 0x7FFFFFFF,
} MMAL_STEREOSCOPIC_MODE_T;
typedef struct MMAL_PARAMETER_STEREOSCOPIC_MODE_T
{
MMAL_PARAMETER_HEADER_T hdr;
MMAL_STEREOSCOPIC_MODE_T mode;
MMAL_BOOL_T decimate;
MMAL_BOOL_T swap_eyes;
} MMAL_PARAMETER_STEREOSCOPIC_MODE_T;
- mode sets up how the stereoscopic image is to be packed - either with the two images side by side, or one above the other (top/bottom).
- decimate is also sometimes referred to as half/half mode. The output frame ends up still being the same size as the original (eg 1920x1080), but the individual images are squashed (2:1) in one dimension to fit them both in (ie each eye would become either 960x1080, or 1920x540, but with non-square pixels).
- swap_eyes allows putting the image for the right eye on the left/top, and left eye on the right/bottom. Display and H264 generally want swap_eyes=FALSE, JPEG stereoscopic wants swap_eyes=TRUE. NOT IMPLEMENTED YET!
- This is for the compute module only and requires two camera modules (obvious I know!). It is not possible to run it on a standard Pi as only one camera interface is exposed. Please don't ask.
- You MUST enable stereoscopic mode before enabling the camera component or setting the camera number. Stereoscopic mode needs to take control of both cameras and allocate memory differently (read more!), and those actions occur early on. There is a basic check to try and avoid you enabling stereoscopic too late. You can disable it again after the component has been enabled without issue other than having used more memory/resources than necessary.
- You will need to instruct TVService to switch your TV into a stereoscopic mode before running your camera command if you want to view the stereoscopic output. For me that is something like tvservice -m CEA will give you a list of the modes your TV supports.
Code: Select all
tvservice --explicit="CEA_3D_TB 4" tvservice --explicit="CEA_3D_SBS 16"
- The camera number parameter now selects the first channel camera. The second channel is always the other one (seeing as there are only 2 interfaces on this chip)
- The MMAL port format defines the overall image buffer for both images. I haven't written the userland raspistill/vid code cleanly as yet, but for a full side by side 5MPix JPEG you will want to execute something like raspistill -w 5184 -h 1944 -3d sbs -o stereo.jps.
- There are definite restrictions to what can be displayed both on putting things on the display, and what the display can then drive. Exact limits aren't established yet (and you may be able to exceed them with overclocking), but 1080P half/half will certainly work as it is almost no extra over normal 1080P. 720P full frame also works.
- The hardware H264 block has an internal line buffer that will limit you at a maximum of 1920 wide. Please do not exceed that. There is another limitation on the frame height at 1344, so I'm afraid that also means that 720P top/bottom full frame is also out. The width of each image must also be a multiple of 128 (overall width a multiple of 256), so 1920x1080 doesn't work (1920/2 = 960. /128 = 7.5) . raspivid command will be something like raspivid -w 1792 -h 1080 -3d tb -hh -o stereo.264.
This is NOT MVC encoding, just H264 with the two images squashed into one. My understanding from Dom is that XBMC (and omxplayer) will pick up stereoscopic encoding from the filename if it is correctly formatted for it It looks like file.3DSBS.mp4, file1.HSBS.mp4, file2.3DTAB.mp4, and file3.HTAB.mp4 are the four options, but please check XBMC docs/forums for more info - I am no expert on the playback side. - If you ask for an I420 or similar encoding, then you should get a buffer the size of the MMAL port format with the two stereoscopic images packed in the desired format.
- All the camera settings (AGC, AWB etc) are slaved off the primary sensor. Covering the lens on one sensor will either have no effect (if the primary) or result in the other eye over saturating (if the secondary). This is expected behaviour.
- This will NOT be supported through V4L2 - the V4L2 API currently doesn't appear to have any calls or parameters relating to stereoscopic video, and I'm not going to be adding them
Have fun.
edit Correction that 1920 wide will not work with H264 encode as it is not a multiple of 256.