Skip to main content
Version: v1.1

Sample - Python Video Device

This repository contains a Python video device example for building and deploying a service on the AosEdge platform. Follow this guide to set up your environment, pass a video device from the board to the service, create the service in AosCloud, and sign and upload the service bundle.

Prerequisites

  • Target unit: a video supported device (Raspberry Pi).
  • AosCloud account: an SP user account for AosCloud. See the AosEdge dictionary for user types and the Get access page for login help.
  • Tools: AosCore SDK, SQLite, CMake, Bash, Wget, Python, and a virtual environment (venv) are installed.

Source Code

You can explore the example by checking out the source code.

Adding video device to service

To use a video device (such as a USB webcam) in the AOS system, follow these steps:

Connecting and detecting video device

  1. Connect your video device to the Raspberry Pi board.

  2. Start the device and connect to it via terminal.

  3. Switch to the DomD partition.

  4. Run the following command to list available video devices:

    v4l2-ctl --list-devices
    (XEN) root@main:~# v4l2-ctl --list-devices
    (XEN) GENERAL WEBCAM: GENERAL WEBCAM (usb-xhci-hcd.1.auto-1):
    (XEN) /dev/video0
    (XEN) /dev/video1
    (XEN) /dev/media0
  5. Copy the device paths — you will need them in the next steps.

Configure Resources on Node

Video devices should be configured directly on the node in /etc/aos/resources.cfg.

  1. Open the resources configuration file on the node:

    nano /etc/aos/resources.cfg
  2. Add a resource entry for the camera device.

    Example:

    [
    {
    "name": "camera0",
    "devices": [
    "/dev/video0",
    "/dev/video1",
    "/dev/media0"
    ],
    "groups": [
    "video"
    ],
    "sharedCount": 2
    }
    ]
  3. Save the file.

Done! Camera resources are now available on the node for services that request camera0.

Upload service to AosCloud

From the video_device directory, run:

<host>:~/demo-services/video_device$ aos-signer go
Starting DEPLOYMENT BUNDLE SIGNING process...
Starting CONFIG VALIDATION process...
Validating config... VALID
Validating image paths... VALID
Starting BUNDLE BUILDING process...
....
Uploading... DONE
Deployment bundle successfully uploaded!

Validate Result of Service

  1. For detailed instructions on working with logs, see Get service logs.

  2. Download the log file from your device and find Running: v4l2-ctl --list-devices. This indicates that v4l2-ctl was executed to print the list of video devices available on your unit.