waveform80 / picamera

A pure Python interface to the Raspberry Pi camera module
https://picamera.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.57k stars 355 forks source link

Preview on 2nd Display (Raspberry Pi 4) #626

Closed meirg closed 4 years ago

meirg commented 4 years ago

Is there any way to get the preview to show on a display other than HDMI-0? I have 2 screens connected and want to show the preview on HDMI-1 (display 7) instead of HDMI-0 (display 2).

meirg commented 4 years ago

Figured it out after some more digging. Here is the code if anyone else needs:

from picamera import PiCamera, mmal
camera = PiCamera()
camera.start_preview()
mp = camera.preview.renderer.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION]
mp.set = mmal.MMAL_DISPLAY_SET_NUM
mp.display_num = 7
camera.preview.renderer.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION] = mp