Exemplo n.º 1
0
 def _create_pool(self):
     """
     Allocates a pool of buffers for the encoder
     """
     assert not self.pool
     self.pool = mmal.mmal_port_pool_create(
         self.output_port, self.output_port[0].buffer_num, self.output_port[0].buffer_size
     )
     if not self.pool:
         raise PiCameraError("Failed to create buffer header pool for encoder component")
Exemplo n.º 2
0
 def _create_pool(self):
     """
     Allocates a pool of buffers for the encoder
     """
     assert not self.pool
     self.pool = mmal.mmal_port_pool_create(self.output_port,
                                            self.output_port[0].buffer_num,
                                            self.output_port[0].buffer_size)
     if not self.pool:
         raise PiCameraError(
             "Failed to create buffer header pool for encoder component")
Exemplo n.º 3
0
    def __init__(self,
                 parent,
                 source,
                 size=None,
                 layer=0,
                 alpha=255,
                 fullscreen=True,
                 window=None,
                 crop=None,
                 rotation=0,
                 vflip=False,
                 hflip=False):
        super(PiOverlayRenderer,
              self).__init__(parent, layer, alpha, fullscreen, window, crop,
                             rotation, vflip, hflip)

        # Copy format from camera's preview port, then adjust the encoding to
        # RGB888 and optionally adjust the resolution and size
        port = self.renderer[0].input[0]
        fmt = port[0].format
        mmal.mmal_format_copy(
            fmt,
            parent._camera[0].output[parent.CAMERA_PREVIEW_PORT][0].format)
        fmt[0].encoding = mmal.MMAL_ENCODING_RGB24
        fmt[0].encoding_variant = mmal.MMAL_ENCODING_RGB24
        if size is not None:
            w, h = size
            fmt[0].es[0].video.width = mmal.VCOS_ALIGN_UP(w, 32)
            fmt[0].es[0].video.height = mmal.VCOS_ALIGN_UP(h, 16)
            fmt[0].es[0].video.crop.width = w
            fmt[0].es[0].video.crop.height = h
        mmal_check(mmal.mmal_port_format_commit(port),
                   prefix="Overlay format couldn't be set")
        port[0].buffer_num = port[0].buffer_num_min
        port[0].buffer_size = port[0].buffer_size_recommended

        mmal_check(mmal.mmal_component_enable(self.renderer),
                   prefix="Overlay couldn't be enabled")

        mmal_check(mmal.mmal_port_enable(port, _overlay_callback),
                   prefix="Overlay input port couldn't be enabled")

        self.pool = mmal.mmal_port_pool_create(port, port[0].buffer_num,
                                               port[0].buffer_size)
        if not self.pool:
            raise PiCameraRuntimeError("Couldn't create pool for overlay")

        self.update(source)
Exemplo n.º 4
0
    def __init__(
            self, parent, source, size=None, layer=0, alpha=255,
            fullscreen=True, window=None, crop=None, rotation=0, vflip=False,
            hflip=False):
        super(PiOverlayRenderer, self).__init__(
            parent, layer, alpha, fullscreen, window, crop,
            rotation, vflip, hflip)

        # Copy format from camera's preview port, then adjust the encoding to
        # RGB888 and optionally adjust the resolution and size
        port = self.renderer[0].input[0]
        fmt = port[0].format
        mmal.mmal_format_copy(
            fmt, parent._camera[0].output[parent.CAMERA_PREVIEW_PORT][0].format)
        fmt[0].encoding = mmal.MMAL_ENCODING_RGB24
        fmt[0].encoding_variant = mmal.MMAL_ENCODING_RGB24
        if size is not None:
            w, h = size
            fmt[0].es[0].video.width = mmal.VCOS_ALIGN_UP(w, 32)
            fmt[0].es[0].video.height = mmal.VCOS_ALIGN_UP(h, 16)
            fmt[0].es[0].video.crop.width = w
            fmt[0].es[0].video.crop.height = h
        mmal_check(
            mmal.mmal_port_format_commit(port),
            prefix="Overlay format couldn't be set")
        port[0].buffer_num = port[0].buffer_num_min
        port[0].buffer_size = port[0].buffer_size_recommended

        mmal_check(
            mmal.mmal_component_enable(self.renderer),
            prefix="Overlay couldn't be enabled")

        mmal_check(
            mmal.mmal_port_enable(port, _overlay_callback),
            prefix="Overlay input port couldn't be enabled")

        self.pool = mmal.mmal_port_pool_create(
            port, port[0].buffer_num, port[0].buffer_size)
        if not self.pool:
            raise PiCameraRuntimeError("Couldn't create pool for overlay")

        self.update(source)