platypush/plugins/camera/__init__.py
def open_device(self, device: Optional[Union[int, str]] = None, stream: bool = False, **params) -> Camera:
        """
        Initialize and open a device.

        :return: The initialized camera device.
        :raises: :class:`platypush.plugins.camera.CaptureSessionAlreadyRunningException`
        """
        info = self._merge_info(**params)
        if device is None:
            device = info.device
        elif device not in self._devices:
            info.device = device
        else:
            info = self._devices[device].info.clone()

        assert device is not None, 'No device specified/configured'
        if device in self._devices:
            camera = self._devices[device]
            if camera.capture_thread and camera.capture_thread.is_alive() and camera.start_event.is_set():
                raise CaptureAlreadyRunningException(device)

            camera.start_event.clear()
            camera.capture_thread = None
        else:
            # noinspection PyArgumentList
            camera = self._camera_class(info=info)

        camera.info.set(**params)
        camera.object = self.prepare_device(camera)

        if stream:
            writer_class = StreamWriter.get_class_by_name(camera.info.stream_format)
            camera.stream = writer_class(camera=camera, plugin=self)

        if camera.info.frames_dir:
            pathlib.Path(os.path.abspath(os.path.expanduser(camera.info.frames_dir))).mkdir(
                mode=0o755, exist_ok=True, parents=True)

        self._devices[device] = camera
        return camera

        Initialize and open a device.

        :return: The initialized camera device.
        :raises: :class:`platypush.plugins.camera.CaptureSessionAlreadyRunningException`
        
Initialize and open a device.
Initialize and open a device .
def open_device(self, device: Optional[Union[int, str]] = None, stream: bool = False, **params) -> Camera:
        info = self._merge_info(**params)
        if device is None:
            device = info.device
        elif device not in self._devices:
            info.device = device
        else:
            info = self._devices[device].info.clone()
        assert device is not None, 'No device specified/configured'
        if device in self._devices:
            camera = self._devices[device]
            if camera.capture_thread and camera.capture_thread.is_alive() and camera.start_event.is_set():
                raise CaptureAlreadyRunningException(device)
            camera.start_event.clear()
            camera.capture_thread = None
        else:
            camera = self._camera_class(info=info)
        camera.info.set(**params)
        camera.object = self.prepare_device(camera)
        if stream:
            writer_class = StreamWriter.get_class_by_name(camera.info.stream_format)
            camera.stream = writer_class(camera=camera, plugin=self)
        if camera.info.frames_dir:
            pathlib.Path(os.path.abspath(os.path.expanduser(camera.info.frames_dir))).mkdir(
                mode=0o755, exist_ok=True, parents=True)
        self._devices[device] = camera
        return camera
def open_device ( self , device : Optional [ Union [ int , str ] ] = None , stream : bool = False , ** params ) -> Camera : info = self . _merge_info ( ** params ) if device is None : device = info . device elif device not in self . _devices : info . device = device else : info = self . _devices [ device ] . info . clone ( ) assert device is not None , 'No device specified/configured' if device in self . _devices : camera = self . _devices [ device ] if camera . capture_thread and camera . capture_thread . is_alive ( ) and camera . start_event . is_set ( ) : raise CaptureAlreadyRunningException ( device ) camera . start_event . clear ( ) camera . capture_thread = None else : camera = self . _camera_class ( info = info ) camera . info . set ( ** params ) camera . object = self . prepare_device ( camera ) if stream : writer_class = StreamWriter . get_class_by_name ( camera . info . stream_format ) camera . stream = writer_class ( camera = camera , plugin = self ) if camera . info . frames_dir : pathlib . Path ( os . path . abspath ( os . path . expanduser ( camera . info . frames_dir ) ) ) . mkdir ( mode = 0o755 , exist_ok = True , parents = True ) self . _devices [ device ] = camera return camera
Initialize and open a device.
Initialize and open a device .
"""
        Initialize and open a device.

        :return: The initialized camera device.
        :raises: :class:`platypush.plugins.camera.CaptureSessionAlreadyRunningException`
        """ # noinspection PyArgumentList
The initialized camera device.
The initialized camera device .
None
self
device
Optional[Union[int, str]]
stream
bool