This chapter introduces the GK7206 Video Graphics Subsystem (VGS) sample, sample_vgs. It demonstrates VGS graphics features including cover (masking), OSD (text overlay), luma (brightness), scale, and rotate.
The source lives in sample/vgs/ in the SDK and serves as a reference template for video graphics work.
| Parameter | Value |
|---|---|
Feature index |
0 = cover+osd+luma+scale, 1 = rotate |
Dependency |
sensor + VPSS |
Output |
RTSP stream or VO display |
| index | Name | Command | Expected result |
|---|---|---|---|
| 0 | cover+osd+luma+scale | ./sample_vgs 0 |
Cover and OSD applied, brightness and scale changed, visible over RTSP |
| 1 | rotate | ./sample_vgs 1 |
Image rotated |
sample/vgs/
├── Makefile # build script
└── sample_vgs.c # main program
Before building this application, make sure the following are ready:
# enter the sample directory
cd <SDK_PATH>/sample
# build the vgs sample
make -C vgs clean && make -C vgs
# mount the SD card (recommended)
mkdir -p /sd_card
mount -t vfat /dev/mmcblk1p1 /sd_card
# transfer to the board over SCP
scp sample/vgs/sample_vgs root@<board-IP>:/sd_card/
# make it executable
chmod +x /sd_card/sample_vgs
# enter the SD card directory
cd /sd_card
# run it (index 0: cover+osd+luma+scale)
./sample_vgs 0
# or (index 1: rotate)
./sample_vgs 1
After a successful start the terminal prints output like this:
sample_vgs running
vgs test index: 0
...
rtsp://192.168.1.100:554/livestream/0
After pulling the stream you can see:
This application uses the following architecture:
Sensor -> VI -> VPSS -> VGS -> VENC -> RTSP streaming
// Step 1: system initialization
sample_comm_sys_init(&sys_config);
// Step 2: ISP initialization
sample_comm_isp_init();
// Step 3: start VI
sample_comm_vi_start(...);
// Step 4: start VPSS
sample_comm_vpss_start(...);
// Step 5: VGS initialization
xmedia_vgs_init();
// Step 6: configure the VGS task
xmedia_vgs_handle_t vgs_handle = xmedia_vgs_begin_job(...);
// add the cover task
xmedia_vgs_add_cover_task(vgs_handle, &cover_attr);
// add the OSD task
xmedia_vgs_add_osd_task(vgs_handle, &osd_attr);
// add the luma task
xmedia_vgs_add_luma_task(vgs_handle, &luma_attr);
// submit the job
xmedia_vgs_end_job(vgs_handle);
// Step 7: start VENC
sample_comm_venc_start(...);
// Step 8: bind the modules
xmedia_bind_vpss_to_vgs(...);
xmedia_bind_vgs_to_venc(...);
xmedia_vgs_cover_attr_t cover_attr;
cover_attr.enable = XMEDIA_TRUE;
cover_attr.rect.x = 100;
cover_attr.rect.y = 100;
cover_attr.rect.width = 200;
cover_attr.rect.height = 200;
cover_attr.color = 0xFF0000; // red
xmedia_vgs_osd_attr_t osd_attr;
osd_attr.enable = XMEDIA_TRUE;
osd_attr.rect.x = 10;
osd_attr.rect.y = 10;
osd_attr.rect.width = 200;
osd_attr.rect.height = 30;
osd_attr.font_color = 0xFFFFFF; // white
osd_attr.bg_color = 0x000000; // black
strcpy(osd_attr.text, "Hello VGS");
xmedia_vgs_luma_attr_t luma_attr;
luma_attr.enable = XMEDIA_TRUE;
luma_attr.luma_factor = 120; // 100=normal, >100=brighter, <100=darker
xmedia_vgs_scale_attr_t scale_attr;
scale_attr.enable = XMEDIA_TRUE;
scale_attr.dst_width = 640;
scale_attr.dst_height = 480;
xmedia_vgs_rotate_attr_t rotate_attr;
rotate_attr.enable = XMEDIA_TRUE;
rotate_attr.rotate = VGS_ROTATE_90; // 90/180/270 degrees
| Problem | Likely cause | Fix |
|---|---|---|
| OSD does not appear | Wrong OSD configuration | Check the OSD position and color settings |
| Cover region is wrong | Cover rectangle outside the image | Check that the Cover coordinates are within range |
| Image too bright or too dark | Improper luma value | Set luma to around 100 |
| Scaling distorts the image | Aspect ratio mismatch | Keep the target aspect ratio equal to the source |