platypush/platypush/plugins/camera/pi.py

50 lines
1.2 KiB
Python
Raw Normal View History

2018-06-23 01:00:43 +02:00
"""
.. moduleauthor:: Fabio Manganiello <blacklight86@gmail.com>
"""
from platypush.context import get_backend
from platypush.plugins import Plugin, action
class CameraPiPlugin(Plugin):
2018-06-23 01:00:43 +02:00
"""
Plugin to control a Pi camera.
2018-06-26 00:36:01 +02:00
It acts as a wrapper around the :mod:`platypush.backend.camera.pi` backend
2018-06-23 01:00:43 +02:00
to programmatically control the status.
"""
def __init__(*args, **kwargs):
super().__init__(*args, **kwargs)
@action
def start_recording(self):
2018-06-23 01:00:43 +02:00
"""
Start recording
"""
camera = get_backend('camera.pi')
camera.send_camera_action(camera.CameraAction.START_RECORDING)
@action
def stop_recording(self):
2018-06-23 01:00:43 +02:00
"""
Stop recording
"""
camera = get_backend('camera.pi')
camera.send_camera_action(camera.CameraAction.STOP_RECORDING)
@action
def take_picture(self, image_file):
2018-06-23 01:00:43 +02:00
"""
Take a picture.
:param image_file: Path where the output image will be stored.
:type image_file: str
"""
camera = get_backend('camera.pi')
camera.send_camera_action(camera.CameraAction.TAKE_PICTURE, image_file=image_file)
return {'image_file': image_file}
# vim:sw=4:ts=4:et: