Esempio n. 1
0
 def _set_crop(self, value):
     try:
         x, y, w, h = value
     except (TypeError, ValueError) as e:
         raise PiCameraValueError(
             "Invalid crop rectangle (x, y, w, h) tuple: %s" % value)
     mp = mmal.MMAL_DISPLAYREGION_T(
         mmal.MMAL_PARAMETER_HEADER_T(mmal.MMAL_PARAMETER_DISPLAYREGION,
                                      ct.sizeof(mmal.MMAL_DISPLAYREGION_T)),
         set=mmal.MMAL_DISPLAY_SET_SRC_RECT,
         src_rect=mmal.MMAL_RECT_T(x, y, w, h),
     )
     mmal_check(mmal.mmal_port_parameter_set(self.renderer[0].input[0],
                                             mp.hdr),
                prefix="Failed to set crop")
Esempio n. 2
0
presscount = 1
camera.outputs[0].framesize = (1080, 720)

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

while True:
    buttonstate = GPIO.input(3)
    input_state = GPIO.input(3)
    if buttonstate != lastbuttonstate:
        presscount = presscount + 1
        if presscount % 2 == 0:

            camera.outputs[0].framerate = 25
            p.dest_rect = mmal.MMAL_RECT_T(0, 35, 400, 480)
            mp = camera.control.params[mmal.MMAL_PARAMETER_COLOUR_EFFECT]

            render_l.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION] = p

            p.dest_rect = mmal.MMAL_RECT_T(400, 35, 400, 480)
            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])
        else:
            camera.outputs[0].framerate = 70
            p.dest_rect = mmal.MMAL_RECT_T(0, 35, 400, 480)
            render_l.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION] = p
            p.dest_rect = mmal.MMAL_RECT_T(400, 35, 400, 480)
            render_r.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION] = p
camera = mo.MMALCamera()
splitter = mo.MMALSplitter()
render_l = mo.MMALRenderer()
render_r = mo.MMALRenderer()
# The 960 and 720 are the resolution.  This can be changed to fill your display properly.  I believe I'm using 960 and 1080 on mine.
camera.outputs[0].framesize = (camResW, camResH)
# This originally was 30, but then I the latency is too high and it's nearly impossible to navigate while wearing a head mounted display.
camera.outputs[0].framerate = camFramR
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
# These parameters control the X,Y and scale of the left image showing up on your display
p.dest_rect = mmal.MMAL_RECT_T(cornerX, cornerY, camResW, camResH)
render_l.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION] = p
# These control the X,Y and the scale of the right image showing up on your display.
p.dest_rect = mmal.MMAL_RECT_T(cornerX + windowSpacer + camResW, cornerY,
                               camResW, camResH)
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()

pause()
render_r = mo.MMALRenderer()

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

camera.control.params[mmal.MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS] = 1


p = render_l.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION]
p.set = mmal.MMAL_DISPLAY_SET_FULLSCREEN | mmal.MMAL_DISPLAY_SET_DEST_RECT | mmal.MMAL_DISPLAY_SET_NUM


p.display_num = 2    # HDMI0
p.fullscreen = False
p.dest_rect = mmal.MMAL_RECT_T(0, 18, 500, 500)

render_l.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION] = p


p.display_num = 7    # HDMI1
p.dest_rect = mmal.MMAL_RECT_T(512, 18, 500, 500)

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()