Skip to main content

Camera (CSI)

Omega4 supports camera capture through the RV1103B MIPI CSI-2, CIF, and ISP pipeline. On the Omega4 EVB camera path, the SC3336 sensor is processed by the Rockchip ISP and exposed as a V4L2 capture device, commonly /dev/video7.

Use this page to capture still frames and validate the camera path. For H.264 recording and streaming, see Video Encoder (VENC). For object detection and RKNN inference, see NPU (Edge AI).

Camera and Video Stack

The Omega4 camera path is made of several hardware and software blocks. The camera sensor sends image data into the SoC over MIPI CSI-2, the ISP prepares usable frames, and applications consume those frames through V4L2.

SC3336 camera sensor
-> MIPI CSI-2 receiver
-> Rockchip CIF bridge
-> Rockchip ISP
-> V4L2 capture node, commonly /dev/video7

From the V4L2 capture node, there are three common user workflows:

Still frame workflow:
/dev/video7 -> v4l2-ctl or mfg-camera-test -> NV12 raw frame

Video workflow:
/dev/video7 -> omega4-vencd -> hardware VENC -> H.264 file or stream

Inference workflow:
/dev/video7 -> omega4-rknn-yolo-live -> NPU -> JSON detection output

The rkaiq service runs alongside the capture path. It applies automatic exposure, white balance, and ISP tuning in the background so captured frames look correct.

rkaiq_3A_server -> sensor and ISP controls -> tuned camera output

The onboard video encoder converts camera frames to H.264 directly on the Omega4. It does not create PNG or JPEG still images; for PNG/JPEG output, use a host-side converter or install a target-side image conversion tool that includes those encoders.

Requirements

Camera support is available in Omega4 firmware v0.0.14 and newer.

Useful packages and services:

  • v4l-utils: provides v4l2-ctl and media-ctl.
  • mfg-test-tools: provides mfg-camera-test for quick camera validation.
  • rockchip-aiq: provides the AIQ service that tunes exposure, white balance, color, and other ISP settings.
  • Camera kernel packages for the SC3336 sensor, CSI-2 receiver, CIF bridge, and Rockchip ISP.

Start the AIQ service before judging image quality:

/etc/init.d/rkaiq status || /etc/init.d/rkaiq start
pidof rkaiq_3A_server

Without AIQ, frames may still capture, but exposure, white balance, and color can look poor.

Check the Camera

List the available media and video devices:

ls -l /dev/media* /dev/video* /dev/v4l-subdev* 2>/dev/null
v4l2-ctl --list-devices

Inspect the camera media graph:

media-ctl -p -d /dev/media1

On the EVB camera path, the ISP capture node is commonly /dev/video7. If your image exposes a different node, use the node shown by v4l2-ctl --list-devices and media-ctl -p in the commands below.

Run a quick functional test:

mfg-camera-test -v -d /dev/video7 -n 10

A passing test reports non-zero image data, useful variance, and changing frames.

Capture a Still Frame

To create a PNG or JPEG still image, capture one raw NV12 frame on the Omega4, copy it to a host computer, then convert it with a full FFmpeg build. The default Omega4 ffmpeg-custom package is intended for H.264 transport/remuxing and does not include PNG or MJPEG/JPEG image encoders.

Capture a 640x480 frame:

WIDTH=640
HEIGHT=480
SIZE=$((WIDTH * HEIGHT * 3 / 2))

v4l2-ctl -d /dev/video7 \
--set-fmt-video=width=${WIDTH},height=${HEIGHT},pixelformat=NV12 \
--stream-mmap=4 \
--stream-skip=8 \
--stream-count=1 \
--stream-to=/tmp/frame-${WIDTH}x${HEIGHT}.nv12

ls -lh /tmp/frame-${WIDTH}x${HEIGHT}.nv12
wc -c /tmp/frame-${WIDTH}x${HEIGHT}.nv12
echo "expected bytes: ${SIZE}"

Capture a full-resolution SC3336 frame:

WIDTH=2304
HEIGHT=1296
SIZE=$((WIDTH * HEIGHT * 3 / 2))

v4l2-ctl -d /dev/video7 \
--set-fmt-video=width=${WIDTH},height=${HEIGHT},pixelformat=NV12 \
--stream-mmap=4 \
--stream-skip=8 \
--stream-count=1 \
--stream-to=/tmp/frame-${WIDTH}x${HEIGHT}.nv12

ls -lh /tmp/frame-${WIDTH}x${HEIGHT}.nv12
wc -c /tmp/frame-${WIDTH}x${HEIGHT}.nv12
echo "expected bytes: ${SIZE}"

Copy the raw frame to your host:

scp root@<omega4-ip>:/tmp/frame-640x480.nv12 .

Convert the raw frame to PNG on the host:

ffmpeg -y \
-f rawvideo \
-pixel_format nv12 \
-video_size 640x480 \
-i frame-640x480.nv12 \
-frames:v 1 \
frame-640x480.png

Or convert it to JPEG on the host:

ffmpeg -y \
-f rawvideo \
-pixel_format nv12 \
-video_size 640x480 \
-i frame-640x480.nv12 \
-frames:v 1 \
-q:v 3 \
frame-640x480.jpg

Use a lower -q:v value for higher JPEG quality. Typical values are 2 to 5.

For a full-resolution frame, use -video_size 2304x1296 and the matching raw filename.

Optional target-side conversion is only possible if you install or build an FFmpeg package with the needed image encoders. Check the installed encoders with:

ffmpeg -hide_banner -encoders | grep -E ' png| mjpeg'

Formats and Resolution

List supported capture formats and sizes:

v4l2-ctl -d /dev/video7 --list-formats-ext

Recommended formats:

  • NV12: standard YUV 4:2:0 format. Use this for still capture and VENC input.
  • NV21: similar to NV12, with V and U swapped.
  • UYVY: packed YUV 4:2:2, useful for compatibility tests.
  • NM12 and NM21: Rockchip-specific layouts used by some hardware-accelerated paths.

Use NV12 unless you have a specific reason to choose another format.

Common sizes:

  • 640x480: fast validation and low-bandwidth streaming.
  • 2304x1296: full-resolution SC3336 still capture.

Sensor Controls

Sensor controls are exposed on a V4L2 sub-device. Find the exact sub-device with:

v4l2-ctl --list-devices
media-ctl -p -d /dev/media1

List controls:

v4l2-ctl -d /dev/v4l-subdevX -l

Useful controls include:

  • test_pattern: enables a synthetic sensor pattern for pipeline validation.
  • exposure: adjusts integration time.
  • analogue_gain: adjusts sensor gain.
  • horizontal_flip and vertical_flip: mirror or flip the image.

Disable the test pattern for normal capture:

v4l2-ctl -d /dev/v4l-subdevX -c test_pattern=0

Manually tune exposure and gain if needed:

v4l2-ctl -d /dev/v4l-subdevX -c exposure=900
v4l2-ctl -d /dev/v4l-subdevX -c analogue_gain=4096

Troubleshooting

No /dev/video7

The capture node can change between images. First list the available devices:

v4l2-ctl --list-devices
media-ctl -p -d /dev/media1

If no camera or ISP node appears, check the driver logs:

dmesg | grep -Ei 'sc3336|csi|cif|isp|rkisp|rkcif|mipi|error|timeout'

Black or Very Dark Image

Make sure AIQ is running and give it a few seconds to settle:

/etc/init.d/rkaiq status || /etc/init.d/rkaiq start
sleep 3
mfg-camera-test -v -d /dev/video7 -n 10

If the image is still dark, inspect the sensor and ISP logs:

dmesg | grep -Ei 'sc3336|rkisp|rkcif|csi|mipi|error|timeout'

Gradient or Test Pattern Instead of a Real Image

Disable the sensor test pattern:

v4l2-ctl -d /dev/v4l-subdevX -c test_pattern=0

Unexpected File Size

Confirm the negotiated format:

v4l2-ctl -d /dev/video7 --get-fmt-video

For NV12, expected bytes are width * height * 3 / 2. For UYVY, expected bytes are width * height * 2.