VICAP Sensor Demo#
Introduction#
This example sample_vicap_sensor demonstrates how to use K230 VICAP for camera capture, preview, and Dump.
Pipeline:
Sensor → VICAP DEV0
├─ CHN0 → Dump(YUV / RGB888 / RGB888P / RAW)
└─ CHN1 → VO → Connector(preview, YUV420SP)
Function Description#
Sensor detection: automatically matches according to
-width/-height/-fps/-lane, or is force-specified via-stypeDual channels: CHN0 Dump, CHN1 preview (adapted to screen aspect ratio)
Working mode: see “VICAP Working Mode” below
AE / AWB / HDR / DNR3 / Dewarp
Manual exposure / gain (requires
-ae 0)Mirror / flip (
-mirror/-flip, must take effect before init)Scene loading (
-scene_name/-scene_path)Interactive Dump or
-dump <n>auto Dump and exit
Supported Parameters#
Parameter |
Description |
Default |
|---|---|---|
|
Connector type (required) |
None |
|
Rotation (0 / 90 / 180 / 270) |
0 |
|
CSI index (0–2) |
2 |
|
lane preference during detection (corresponds to |
ANY (unrestricted; ties prefer 2LANE) |
|
Force |
Not set |
|
Target resolution and frame rate for detection |
1920 / 1080 / 30 |
|
CHN0 format: YUV / RGB888 / RGB888P / RAW |
0 |
|
Automatically dump n frames after startup and exit |
Interactive mode |
|
Function switches (0/1) |
1 / 1 / 0 / 0 / 1 |
|
Force |
0 |
|
Manual exposure (microseconds, requires |
— |
|
Manual analog gain (requires |
— |
|
Horizontal mirroring / vertical flipping (0/1) |
0 |
|
Scene name and configuration path |
— |
stype / Connector values are subject to the board-side list_sensor and list_connector.
VICAP Operating Mode#
Examples select dev_attr.mode according to the following rules:
Condition |
Mode |
|---|---|
|
Force SW_TILE |
|
ONLINE (the RAW path does not use SW_TILE by default; |
The capture width or height exceeds the VICAP limit (approximately 3072×2160, such as 4K YUV/RGB) |
SW_TILE |
Other |
ONLINE |
When -ofmt 3 is used, DNR3 is also automatically disabled (to avoid unnecessary overhead on the RAW Dump path).
Interactive Commands#
Command |
Description |
|---|---|
|
Dump 1 frame (CHN0) |
|
Dump n frames |
|
Exit |
Code Location#
src/rtsmart/examples/mpp/sample_vicap_sensor/
sample_vicap_sensor.c— Main program
Usage Instructions#
Compilation#
In the SDK root directory, use make menuconfig to select the corresponding example, then compile the firmware.
Running Examples#
Basic Preview#
./sample_vicap_sensor.elf -c 20
# or specify CSI0
./sample_vicap_sensor.elf -c 20 -s 0
Probe by Resolution / Specify lane#
# Default lane=ANY; in a tie, sorting favors 2LANE
./sample_vicap_sensor.elf -c 20 -s 0 -width 2592 -height 1944 -fps 30
# Explicitly select 4LANE (requires firmware CSI0 LANE NUM=4LANE and 4LANE Configure to be enabled)
./sample_vicap_sensor.elf -c 20 -s 0 -width 2592 -height 1944 -fps 30 -lane 4
# Force type (id is based on list_sensor)
./sample_vicap_sensor.elf -c 20 -s 0 -stype <id> -r 90
CHN0 Dump Format#
./sample_vicap_sensor.elf -c 20 -s 0 -ofmt 0 # YUV420SP
./sample_vicap_sensor.elf -c 20 -s 0 -ofmt 1 # RGB888
./sample_vicap_sensor.elf -c 20 -s 0 -ofmt 2 # RGB888P
./sample_vicap_sensor.elf -c 20 -s 0 -ofmt 3 -dump 1 # RAW, ONLINE, automatically dump 1 frame and exit
Manual Exposure / Gain#
./sample_vicap_sensor.elf -c 20 -ae 0 -exp 10000
./sample_vicap_sensor.elf -c 20 -ae 0 -again 2.0
Other#
./sample_vicap_sensor.elf -c 20 -dnr3 0
./sample_vicap_sensor.elf -c 20 -r 90
./sample_vicap_sensor.elf -c 20 -mirror 1 -flip 0
./sample_vicap_sensor.elf -c 20 -tile 1 # Force SW_TILE (for debugging)
./sample_vicap_sensor.elf -c 20 -scene_name day -scene_path /etc/vicap/day/
Interaction and Output#
Preview running. CHN0 dump (ofmt=0), CHN1 preview
Commands: d / d <n> dump, q quit
Command:
Dump file example:
vicap_dev0_chn0_1920x1080_0000.yuv420sp
vicap_dev0_chn0_1920x1080_0000.raw10
The program unpacks according to stride before writing the file, preventing image corruption caused by line padding.
提示
-exp/-again须配合-ae 0。CHN0 Dump、CHN1 预览;预览宽高按屏幕比例适配,并按 ISP MI 16 / 偶数高对齐。
Connector / Sensor type 用
list_connector、list_sensor查询。同分辨率 2L/4L 与 menuconfig(CSI0 LANE NUM)说明见 如何配置 Sensor。
