Multimedia API: Getting Started

Introduction

The Multimedia API provides a set of classes and functions providing an easy way to write multimedia applications for the Variscite’s SoMs, such as capturing and displaying images using cameras, playing videos, and so on.

Hardware

Supported Cameras

The pyvar package’s Multimedia API supports the following cameras:

See this quick example to open a camera using the multimedia API:

1  # Import the multimedia API from pyvar
2  from pyvar.multimedia.helper import Multimedia
3
4  # Create the object specifying the source (video or camera), and the resolution.
5  foo = Multimedia(source="/dev/video1", resolution="hd")
6
7  # Set the v4l2 configuration.
8  foo.set_v4l2_config()
9
10 # Create a loop to read the frames
11 while foo.loop:
12        # Read the frame
13        frame = foo.get_frame()
14        # do something with the frame, for instance: ML inference.
15        ...
16        # Show the frame
17        foo.show("Camera Example", frame)
18
19 # Destroy the camera object
20 foo.destroy()

Software

Setting up the BSP

  1. Build the latest Yocto Release with Wayland + X11 features using fsl-image-qt5 image;

    NOTE: To use the fsl-image-gui image, make sure to add the following lines at your local.conf file:

    OPENCV_PKGS_imxgpu = " \
       python3-opencv \
    "
    
    IMAGE_INSTALL_append_mx8 = " \
        ${OPENCV_PKGS} \
    "
    
  1. Flash the built image into the SD Card, boot the board, then go to the next section.

Python API Package Installation

  1. To install the pyvar API Python package use the pip3 tool to retrieve it via Pypi:

    root@imx8mp-var-dart:~# pip3 install pyvar
    
  2. To make sure that pyvar is installed, run the following command to check:

    root@imx8mp-var-dart:~# python3
    Python 3.9.5 (default, May  3 2021, 15:11:33)
    [GCC 10.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from pyvar import multimedia
    >>>