Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Camera Plugin for OVOS PHAL

This plugin gives OVOS access to a camera. It uses OpenCV on most systems and libcamera on Raspberry Pi. The plugin can take snapshots, serve a video stream over HTTP, and respond to camera commands sent over the message bus.

Features

  • Detect and use a compatible camera system: libcamera on Raspberry Pi, or OpenCV on other systems.
  • Open and close the camera on demand.
  • Capture frames and save them to a file, or return them as base64-encoded strings.
  • Serve a video stream as an MJPEG feed over HTTP.

HiveMind Support

You can use this plugin in OVOS and with HiveMind satellites.

Allow "ovos.phal.camera.pong" in your HiveMind so your satellite can report camera support:

hivemind-core allow-msg "ovos.phal.camera.pong"

Installation

  1. Install the plugin:

    pip install ovos-phal-plugin-camera
    
  2. Add the plugin to your OVOS PHAL configuration:

    {
        "PHAL": {
            "ovos-phal-plugin-camera": {
                "video_source": 0,
                "start_open": false,
                "serve_mjpeg": false,
                "mjpeg_host": "0.0.0.0",
                "mjpeg_port": 5000
            }
        }
    }
    

Additional Steps for Raspberry Pi Users

On Raspberry Pi, the Picamera2 library needs the libcamera package. Raspberry Pi OS installs libcamera system-wide, so a Python virtual environment (venv) needs extra setup to reach it.

These examples use the default venv location from ovos-installer, ~/.venvs/ovos. Adjust the path if your setup differs.

Steps to Enable libcamera in Your Virtual Environment

  1. Install the required system packages:

    sudo apt install -y python3-libcamera python3-kms++ libcap-dev
    
  2. Open the pyvenv.cfg file in your virtual environment directory:

    nano ~/.venvs/ovos/pyvenv.cfg
    

    Add or update this line:

    include-system-site-packages = true
    

    Save the file and close the editor.

  3. Activate your virtual environment:

    source ~/.venvs/ovos/bin/activate
    

    Check that libcamera is accessible:

    python3 -c "import libcamera; print('libcamera is accessible')"
    

Why These Steps Are Necessary

The libcamera package is not on PyPI. Raspberry Pi OS installs it system-wide. A virtual environment isolates itself from system-wide Python packages by default, so these steps let the plugin reach libcamera while the venv still isolates other packages.

Notes

  • These steps apply only to Raspberry Pi users who use the Picamera2 library. On other platforms, the plugin uses OpenCV, which needs no extra configuration.

  • Before you run these steps, confirm libcamera is installed on your Raspberry Pi:

    libcamera-still --version
    

Configuration Options

Option Type Default Description
video_source int 0 Index of the video source to use for the camera.
start_open bool false Whether to open the camera at plugin startup.
serve_mjpeg bool false Whether to start an MJPEG server for video streaming.
mjpeg_port int 5000 Port for the MJPEG server.

Bus Events

Handled Events

Event Name Description Payload
ovos.phal.camera.open Opens the camera. None
ovos.phal.camera.close Closes the camera. None
ovos.phal.camera.get Captures a frame from the camera. { "path": "<file_path>" }

Emitted Events

Event Name Description Payload
ovos.phal.camera.get.response Response for the captured frame. { "path": "<file_path>" } or { "b64_frame": "<base64_data>" }

Usage

Open the Camera

Send this message to open the camera:

bus.emit(Message("ovos.phal.camera.open"))

Close the Camera

Send this message to close the camera:

bus.emit(Message("ovos.phal.camera.close"))

Capture a Frame

Send this message to capture a frame:

bus.emit(Message("ovos.phal.camera.get", {"path": "/path/to/save/image.jpg"}))

If you do not provide a path, the plugin returns the frame as a base64-encoded string.

MJPEG Server

If you enable serve_mjpeg in the configuration, the MJPEG feed is available at:

http://<mjpeg_host>:<mjpeg_port>/video_feed

You can use the MJPEG feed to integrate this camera into Home Assistant.


Related Projects


License

This project is licensed under the Apache 2.0 License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ovos_phal_plugin_camera-0.2.3a2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ovos_phal_plugin_camera-0.2.3a2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file ovos_phal_plugin_camera-0.2.3a2.tar.gz.

File metadata

File hashes

Hashes for ovos_phal_plugin_camera-0.2.3a2.tar.gz
Algorithm Hash digest
SHA256 c036f027cd9f5a80b4087d790e401bd553ff2d51976411da102c26c98ca23ff3
MD5 dee2a6fce6a026239e6135d942ec58be
BLAKE2b-256 adfe4568cab90b13e7f753749c663b063c9feb21f230e1fd62d4372d6be9f42a

See more details on using hashes here.

File details

Details for the file ovos_phal_plugin_camera-0.2.3a2-py3-none-any.whl.

File metadata

File hashes

Hashes for ovos_phal_plugin_camera-0.2.3a2-py3-none-any.whl
Algorithm Hash digest
SHA256 79ce3b1b30e42e02a8d32efbbaf2719c013f095641fa0b7d61766a87e9729997
MD5 9505deeee186d4854c078fef15a5fb1c
BLAKE2b-256 3c0c32674e6ad3007142cbdc3e8cefd94cfe90446b830e3f8341af1c1eecf81c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.3a2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page