Skip to content

Camera

Testing MIPI-CSI2 and Parallel CSI Cameras

Before running any of the pipelines below, make sure you have the camera(s) connected to the board. The i.MX family of processors uses GStreamer as a multimedia framework. Please refer to https://gstreamer.freedesktop.org/.

Install Utils

Run the following command to install v4l-utils:

apt-get clean; apt-get update; apt-get install -y v4l-utils

Camera Probe

Run the following command to list the detected camera devices:

v4l2-ctl --list-devices

This should produce output similar to the following:

amphion vpu decoder (platform:amphion-vpu):
        /dev/video0
        /dev/video1

mxc-isi-cap_v1 (platform:58100000.isi:cap_devic):
        /dev/video3

mxc-isi-m2m_v1 (platform:58100000.isi:m2m_devic):
        /dev/video2

mxc-isi-cap_v1 (platform:58140000.isi:cap_devic):
        /dev/video4

There are two cameras: the MIPI-CSI2 VCAM-5640S is accessible as /dev/video3, and the parallel CSI VCAM-5640P is accessible as /dev/video4. The /dev/video0 and /dev/video1 nodes are VPU codec devices, not camera capture devices.

Testing Camera Preview on Display

The examples below use the MIPI-CSI2 VCAM-5640S at /dev/video3. Use /dev/video4 for the parallel CSI VCAM-5640P.

  • VGA 480p 640x480@30fps:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=640,height=480 ! autovideosink sync=false
  • NTSC 480p 720x480@30fps:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=720,height=480 ! autovideosink sync=false
  • HD 720p 1280x720@30fps:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=1280,height=720 ! autovideosink sync=false
  • Full HD 1080p 1920x1080@30fps:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=1920,height=1080 ! autovideosink sync=false
  • QSXGA 1944p 2592x1944@15fps:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=2592,height=1944 ! autovideosink sync=false

Note: The parallel camera maximal frame rate at the 1920x1080 and 2592x1944 resolutions is 7.5fps.

Testing Camera JPEG Snapshot

The examples below use the MIPI-CSI2 VCAM-5640S at /dev/video3. Use /dev/video4 for the parallel CSI VCAM-5640P.

  • VGA 480p 640x480:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=640,height=480 ! jpegenc ! filesink location=/tmp/test_640x480.jpg
  • NTSC 480p 720x480:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=720,height=480 ! jpegenc ! filesink location=/tmp/test_720x480.jpg
  • HD 720p 1280x720:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=1280,height=720 ! jpegenc ! filesink location=/tmp/test_1280x720.jpg
  • Full HD 1080p 1920x1080:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=1920,height=1080 ! jpegenc ! filesink location=/tmp/test_1920x1080.jpg
  • QSXGA 1944p 2592x1944:
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=2592,height=1944 ! jpegenc ! filesink location=/tmp/test_2592x1944.jpg

Using 2 Cameras Simultaneously

The following pipeline saves a short MJPEG-encoded AVI stream from each camera:

WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! jpegenc ! avimux ! filesink location=./test0.avi \
                                     v4l2src device=/dev/video4 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! jpegenc ! avimux ! filesink location=./test1.avi