thendualism
Posts: 1
Joined: Tue Jan 08, 2019 10:59 pm

One camera, 2 preview windows. Is this possible?

Tue Feb 05, 2019 11:45 pm

I'm a total noob with this, but I have a regular RPi 3 B+ with the standard camera module. I can get the preview to work just fine with one window, but is there any way to do it such that there are two preview windows side by side? (Similar to VR output)

Here is what I have so far:
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.resolution(640,480)
camera.preview_fullscreen = false
camera.preview_window(0,0,640,480)
camera.start_preview()
sleep(10)
camera.stop_preview()

Doub
Posts: 26
Joined: Fri Apr 07, 2017 9:48 pm

Re: One camera, 2 preview windows. Is this possible?

Wed Feb 06, 2019 10:11 am

I think the PiCamera wraps and connect the camera and renderer components. What you need is insert a splitter and add a second renderer. You probably need to go one level deeper into the MMAL binding and connect the components yourself. Maybe get the sources for the PiCamera class and modify it to suit your needs.

TufRat
Posts: 3
Joined: Wed Oct 30, 2019 8:22 pm

Re: One camera, 2 preview windows. Is this possible?

Fri Dec 13, 2019 12:07 am

I have this working, if you are still looking for a way to do this:

Code: Select all

from picamera import mmalobj as mo, mmal
from signal import pause

camera = mo.MMALCamera()
splitter = mo.MMALSplitter()
render_l = mo.MMALRenderer()
render_r = mo.MMALRenderer()

camera.outputs[0].framesize = (1080, 960)
camera.outputs[0].framerate = 30
camera.outputs[0].commit()

p = render_l.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION]
p.set = mmal.MMAL_DISPLAY_SET_FULLSCREEN | mmal.MMAL_DISPLAY_SET_DEST_RECT
p.fullscreen = False
p.dest_rect = mmal.MMAL_RECT_T(0, 0, 1080, 960)
render_l.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION] = p
p.dest_rect = mmal.MMAL_RECT_T(0, 960, 1080, 960)
render_r.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION] = p

splitter.connect(camera.outputs[0])
render_l.connect(splitter.outputs[0])
render_r.connect(splitter.outputs[1])

splitter.enable()
render_l.enable()
render_r.enable()

Return to “Camera board”