Skip to content

Camera Testing

The camera is an important input device for the development board. Through this test, you can quickly verify:

  • Whether image capture functions are available (photo capture, preview, recording)
  • Whether basic image quality is acceptable (clarity, color, light adaptation)

Hardware Installation

The camera testing chapter uses K7 as an operation example, only showing MIPI camera connection details. Different motherboard models have different MIPI camera interface positions. Please refer to the specification sheet to find the corresponding MIPI camera interface.

Warning

1. Do not install or remove the camera while the device is powered on!
2. To better show the connection details, the camera is placed in this manner. For actual use, do not refer to this placement method.

  • FPC Vertical Pull-up Interface: Do not insert the FPC cable directly into the FPC interface. Pull up the black module on the interface, insert the FPC cable, then press the black module down again.

image-20260120162028182

  • FPC Flip-top Interface: Do not insert the FPC cable directly into the FPC interface. Flip up the black module on the interface, insert the FPC cable, then press the black module down again.

image-20260526103427719

Command Line Testing

In Linux systems, install v4l2-ctl and GStreamer to verify camera functionality. v4l2-ctl is a command-line tool dedicated to controlling and managing camera devices on Linux systems (quickly checking whether the camera is recognized by the system, debugging image parameters, obtaining device capability information). GStreamer is a multimedia processing framework that can build flexible multimedia processing pipelines (suitable for video functionality testing, recording performance evaluation, and streaming application development verification).

v4l2-ctl

v4l2-ctl is a command-line tool for controlling V4L2 (Video4Linux2) video devices on Linux systems. Its core purpose is to configure and query parameters of cameras, video capture cards, and other devices.

Install the Tool

sudo apt update
sudo apt install v4l-utils

Camera Nodes

  • List camera devices:
sudo v4l2-ctl --list-devices

Example: Through rkisp_mainpath, we can see two cameras. Generally, operate the corresponding first devices /dev/video33 and /dev/video42.

root@linaro-alip:/#sudo v4l2-ctl --list-devices
...
rkisp_mainpath (platform:rkisp-vir0):
        /dev/video33
        /dev/video34
        /dev/video35
        /dev/video36
        /dev/video37
        /dev/video38
        /dev/video41
        /dev/media3

rkisp_mainpath (platform:rkisp-vir1):
        /dev/video42
        /dev/video43
        /dev/video44
        /dev/video45
        /dev/video46
        /dev/video47
        /dev/video50
        /dev/media4
...

Camera Information

  • Query the detailed formats supported by a specified camera node:
sudo v4l2-ctl --list-formats-ext --device=/dev/video*

Example: Check camera information for the /dev/video33 node.

root@linaro-alip:/#sudo v4l2-ctl --list-formats-ext --device=/dev/video33
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'UYVY' (UYVY 4:2:2)
                Size: Stepwise 32x32 - 3840x2160 with step 8/8
        [1]: 'NV16' (Y/UV 4:2:2)
                Size: Stepwise 32x32 - 3840x2160 with step 8/8
        [2]: 'NV61' (Y/VU 4:2:2)
                Size: Stepwise 32x32 - 3840x2160 with step 8/8
        [3]: 'NV21' (Y/VU 4:2:0)
                Size: Stepwise 32x32 - 3840x2160 with step 8/8
        [4]: 'NV12' (Y/UV 4:2:0)
                Size: Stepwise 32x32 - 3840x2160 with step 8/8
        [5]: 'NM21' (Y/VU 4:2:0 (N-C))
                Size: Stepwise 32x32 - 3840x2160 with step 8/8
        [6]: 'NM12' (Y/UV 4:2:0 (N-C))
                Size: Stepwise 32x32 - 3840x2160 with step 8/8

Camera Frame Rate

sudo v4l2-ctl -d /dev/video* \
 --set-fmt-video=width=1920,height=1080,pixelformat='MJPG' \
 --stream-mmap=4 \
 --set-selection=target=crop,flags=0,top=0,left=0,width=1920,height=1080 \
 --stream-count=500

Example:

root@linaro-alip:/#sudo v4l2-ctl -d /dev/video33 \
 --set-fmt-video=width=3840,height=2160\
 --stream-mmap=4 \
 --set-selection=target=crop,flags=0,top=0,left=0,width=3840,height=2160 \
 --stream-count=500
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<^C
root@linaro-alip:/#

Note

Command Explanation:
1. v4l2-ctl -d /dev/video33:
v4l2-ctl: Video4Linux2 control tool, used to configure and control V4L2-compatible video devices.
-d /dev/video33: Specifies the video device to operate as /dev/video33.
2. --set-fmt-video=width=1920,height=1080,pixelformat='MJPG': Configure the video output format.
width=1920,height=1080: Set the video resolution to 1920x1080 (1080P).
pixelformat='MJPG': Set the pixel format to MJPEG (Motion JPEG, a compressed format).
3. --stream-mmap=4: Enable memory mapping (mmap) mode to capture the video stream. =4 means allocating 4 buffers for stream capture (multiple buffers can reduce frame loss).
4. --set-selection=target=crop,flags=0,top=0,left=0,width=1920,height=1080: Set the video cropping area.
target=crop: Specifies the operation target as the cropping area.
flags=0: No special flags (default).
top=0,left=0,width=1920,height=1080: Set the cropping area starting from the top-left corner (0,0) with a size of 1920x1080 (using the full frame, no cropping).
5. --stream-count=500: Specifies to capture 500 video frames, stopping automatically after completion.

GStreamer

GStreamer is a cross-platform, open-source multimedia framework. Its core positioning is a "pipeline engine" for multimedia processing. It can split audio/video capture, encoding, decoding, filtering, transmission, and rendering into independent "plugins", then flexibly combine them through "pipelines" to quickly implement complex multimedia applications (such as video playback, live streaming, audio/video transcoding, camera capture, etc.).

Install the Tool

sudo apt update
sudo apt install gstreamer1.0-tools
sudo apt install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
sudo usermod -aG video $USER

Capture Image via Command Line

sudo gst-launch-1.0 v4l2src num-buffers=1 device=/dev/video* ! jpegenc ! filesink location=picture.jpg

Preview via Command Line

  • autovideosink method:
sudo gst-launch-1.0 v4l2src device=/dev/video* ! video/x-raw,format=NV12,width=800,height=600,framerate=30/1 ! videoconvert ! autovideosink
  • waylandsink method (for preview on GNOME Wayland architecture desktops):
sudo gst-launch-1.0 v4l2src device=/dev/video* ! video/x-raw,width=1280,height=720,framerate=30/1 ! videoconvert ! waylandsink

Example:

sudo gst-launch-1.0 v4l2src device=/dev/video33 ! video/x-raw,width=800,height=600,framerate=30/1 ! videoconvert ! waylandsink

Note

Command Explanation:
1. gst-launch-1.0: GStreamer's command-line tool for quickly building and running GStreamer pipelines.
2. v4l2src device=/dev/video33:
v4l2src: Video4Linux2 source element, used to capture data from V4L2-compatible video devices (such as cameras).
device=/dev/video33: Specifies the video device file to use, here /dev/video33 (camera numbers may vary for different devices).
3. video/x-raw,format=NV12,width=800,height=600,framerate=30/1: Specifies the video format.
video/x-raw: Indicates raw uncompressed video.
format=NV12: Video pixel format is NV12 (a common YUV format suitable for hardware acceleration).
width=800,height=600: Video resolution is 800x600.
framerate=30/1: Frame rate is 30 frames/second.
4. videoconvert: Video format conversion element, used to convert the input video format to a format supported by subsequent elements (mainly to meet the requirements of display elements).
5. autovideosink: Automatically selects an appropriate video output element based on the system environment (such as X11, Wayland, or direct rendering).