VICAP Sensor Demo#
Overview#
The sample_vicap_sensor demo shows how to use the K230 VICAP (Video Capture) module for camera image capture and display. The VICAP module supports multiple camera sensors and can be used for video input, frame capture, and dump operations.
Functional Description#
VICAP Features#
This sample demonstrates the main VICAP capabilities:
automatic camera detection and sensor initialization
real-time image capture
custom sensor resolution and frame-rate configuration
automatic aspect-ratio adaptation so the image is not stretched on screen
dual-channel output:
CHN0for dump, withYUV,RGB, andRAWformatsCHN1for preview display inYUV420SP
automatic and manual exposure control in microseconds
auto white balance (AWB)
HDR support
3D noise reduction (
DNR3), enabled by defaultdewarp support for image distortion correction
Supported Parameters#
Parameter |
Description |
Default |
|---|---|---|
|
connector type, required |
none |
|
rotation angle ( |
|
|
CSI index ( |
|
|
AE status ( |
|
|
AWB status ( |
|
|
HDR status ( |
|
|
dewarp status ( |
|
|
manual exposure time in microseconds |
- |
|
sensor width |
|
|
sensor height |
|
|
sensor frame rate |
|
|
|
|
|
|
|
|
manual analog gain, requires |
- |
Interactive Commands#
After the program starts, the following commands are available:
Command |
Description |
|---|---|
|
dump one frame from |
|
dump |
|
quit the program |
Source Location#
src/rtsmart/examples/mpp/sample_vicap_sensor/
Main file:
sample_vicap_sensor.c- main program source
Usage#
Build#
In the K230 RTOS SDK root, use make menuconfig to enable the VICAP Sensor sample in the firmware, then rebuild the firmware.
Run Examples#
Basic Preview#
./sample_vicap_sensor.elf -c 20
Custom Resolution and Frame Rate#
./sample_vicap_sensor.elf -c 20 -width 1280 -height 720 -fps 60
Enable CHN0 Dump in YUV Format#
./sample_vicap_sensor.elf -c 20 -ofmt 0
Manual Exposure#
# set exposure to 10000 microseconds (10 ms), AE must be disabled
./sample_vicap_sensor.elf -c 20 -ae 0 -exp 10000
Manual Gain#
# set gain to 1.0, AE must be disabled
./sample_vicap_sensor.elf -c 20 -ae 0 -again 1.0
Disable DNR3#
./sample_vicap_sensor.elf -c 20 -dnr3 0
Rotated Display#
# rotate by 90 degrees
./sample_vicap_sensor.elf -c 20 -r 90
Interactive Operation#
After startup, the command menu looks like:
Preview running.
CHN0: dump (format=0), CHN1: preview
Commands: d=dump 1 frame, d <n>=dump n frames, q=quit
---------------------------------------
Input command:
d - Dump one frame
d <n> - Dump n frames
q - Quit
---------------------------------------
Command:
Enter d or d 5 to dump images to files.
Expected Result#
At runtime, the program will:
detect and initialize the camera sensor
query the sensor resolution and exposure range
calculate the output size according to the screen aspect ratio
configure VICAP dual channels, with
CHN0for dump andCHN1for previewbind VICAP to the VO display layer
start image capture and display
Representative output:
INFO: Sensor resolution: 1920x1080
INFO: Sensor fd = 5
sample_vicap_sensor: connector=20, screen_size=1920x1080, output_size=1920x1080, layer=1, rotate=0, csi=2
Aspect ratio mode: sensor=1.78, screen=1.78
CHN0 format: 0 (0=yuv, 1=rgb888, 2=rgb888p, 3=raw)
Fullscreen mode (offset_x=0, offset_y=0)
VICAP features: AE=1, AWB=1, HDR=0, Dewarp=0, DNR3=1, Again=1.00
Bind VICAP(dev=0, ch=1) -> VO(layer=1) OK
Starting VICAP stream on dev0 ch0 ...
INFO: Manual exposure set to 10000 us (0.010000 sec), range: 0.000030-0.033333 sec
Preview running.
CHN0: dump (format=0), CHN1: preview
Commands: d=dump 1 frame, d <n>=dump n frames, q=quit
Dump files are saved with names like:
vicap_dev0_chn0_1920x1080_0000.yuv420sp
vicap_dev0_chn0_1920x1080_0001.yuv420sp
...
Tip
When configuring manual exposure, disable AE first with
-ae 0.Exposure values must be within the sensor-supported range; the program checks and prints the valid range automatically.
CHN0is used for dump and supports multiple formats;CHN1is used for preview and is fixed toYUV420SP.The output resolution is adjusted automatically according to the screen aspect ratio to avoid stretching.
Notes
When using
-exp, you must also set-ae 0.When using
-again, you must also set-ae 0.The exposure unit is microseconds (
us), for example10000means10 ms.The gain range depends on the sensor and is checked by the program.
Dump is triggered by interactive commands, not a command-line option.
Width is automatically aligned to a multiple of 8 as required by the hardware.
