Skip to content

Camera

Testing MIPI-CSI2 and parallel CSI cameras

Make sure you have the camera(s) connected to the board before booting it and running any of the pipelines below. The i.MX family of SoCs uses GStreamer as a multimedia framework. Please refer to https://gstreamer.freedesktop.org/

Camera Probe

Run the following command to list the detected camera devices:

v4l2-ctl --list-devices

This should produce the following output:

v4l2-ctl --list-devices
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.

  • 480p (640x480):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=640,height=480 ! autovideosink sync=false
  • NTSC (720x480):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=720,height=480 ! autovideosink sync=false
  • 720p (1280x720):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=1280,height=720 ! autovideosink sync=false
  • 1080p (1920x1080):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=1920,height=1080 ! autovideosink sync=false
  • QSXGA (2592x1944):
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

To capture a JPEG snapshot run one of the pipelines below, depending upon the required picture resolution. The examples below use the MIPI-CSI2 VCAM-5640S at /dev/video3. Use /dev/video4 for the parallel CSI VCAM-5640P.

  • 480p (640x480):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=640,height=480 ! v4l2jpegenc ! filesink location=/tmp/test.jpg
  • NTSC (720x480):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=720,height=480 ! v4l2jpegenc ! filesink location=/tmp/test.jpg
  • 720p (1280x720):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=1280,height=720 ! v4l2jpegenc ! filesink location=/tmp/test.jpg
  • 1080p (1920x1080):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=1920,height=1080 ! v4l2jpegenc ! filesink location=/tmp/test.jpg
  • QSXGA (2592x1944):
WAYLAND_DISPLAY=wayland-1 gst-launch-1.0 v4l2src device=/dev/video3 num-buffers=1 ! video/x-raw,width=2592,height=1944 ! v4l2jpegenc ! filesink location=/tmp/test.jpg

Using 2 cameras simultaneously

The following pipeline is an example of using 2 cameras simultaneously. In this example a short video stream from each camera is saved as an MJPEG-encoded AVI file.

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