Video Graphics Subsystem (VGS) Application
This chapter describes the GK7206 video graphics subsystem (VGS) application example — sample_vgs. The application demonstrates the various graphics processing functions of VGS, including cover (masking), OSD (text overlay), luma (brightness adjustment), scale (resizing), rotate (rotation), and more.
The application source code is located in the SDK directory sample/vgs/. It serves as a reference template for developing video graphics processing applications.
1 Application Overview
1.1 Features
- Cover (masking): adds masking regions on top of the video picture
- OSD (text overlay): overlays text and time information on the video picture
- Luma (brightness adjustment): adjusts the brightness of the video picture
- Scale (resizing): resizes the video picture
- Rotate (rotation): rotates the video picture (90°/180°/270°)
1.2 Technical Specifications
| Parameter | Value |
|---|---|
Function index | 0=cover+osd+luma+scale, 1=rotate |
Dependencies | sensor + VPSS |
Output | RTSP stream or VO display |
1.3 Test Case List
| index | Name | Command | Expected behavior |
|---|---|---|---|
| 0 | cover+osd+luma+scale | ./sample_vgs 0 | Cover/OSD overlaid, brightness adjusted, picture scaled; visible over RTSP |
| 1 | rotate | ./sample_vgs 1 | Picture rotated |
1.4 Directory Structure
sample/vgs/
├── Makefile # Build script
└── sample_vgs.c # Main program2 Build and Deployment
2.1 Prerequisites
Before building this application, make sure the following preparations have been completed:
- SDK environment is set up: follow SDK Compilation to set up the cross-compilation toolchain and SDK configuration
- Sensor is connected: an SC465SL or compatible image sensor must be connected
2.2 Build the Application
# Enter the sample directory
cd <SDK_PATH>/sample
# Build the vgs sample
make -C vgs clean && make -C vgs2.3 Deploy to the Board
# Mount the SD card (recommended)
mkdir -p /sd_card
mount -t vfat /dev/mmcblk1p1 /sd_card
# Transfer to the development board via SCP
scp sample/vgs/sample_vgs root@<board IP>:/sd_card/2.4 Run the Application
# Add execute permission
chmod +x /sd_card/sample_vgs
# Enter the SD card directory
cd /sd_card
# Run (index 0: cover+osd+luma+scale)
./sample_vgs 0
# Or (index 1: rotate)
./sample_vgs 12.5 Expected Output
After a successful run, the terminal prints information similar to the following:
sample_vgs running
vgs test index: 0
...
rtsp://192.168.1.100:554/livestream/0After pulling the stream you can see:
- A masking region on the picture (cover)
- Overlaid text on the picture (OSD)
- The picture brightness has been adjusted (luma)
- The picture size has changed (scale)
3 Internal Execution Logic in Detail
3.1 Application Architecture
The application uses the following architecture:
Sensor → VI → VPSS → VGS → VENC → RTSP streaming3.2 VGS Initialization Flow
// 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: Initialize VGS
xmedia_vgs_init();
// Step 6: Configure the VGS tasks
xmedia_vgs_handle_t vgs_handle = xmedia_vgs_begin_job(...);
// Add a cover task
xmedia_vgs_add_cover_task(vgs_handle, &cover_attr);
// Add an OSD task
xmedia_vgs_add_osd_task(vgs_handle, &osd_attr);
// Add a luma task
xmedia_vgs_add_luma_task(vgs_handle, &luma_attr);
// Submit the tasks
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(...);4 Key Programming Points
4.1 Cover Configuration
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; // Red4.2 OSD Configuration
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");4.3 Luma Configuration
xmedia_vgs_luma_attr_t luma_attr;
luma_attr.enable = XMEDIA_TRUE;
luma_attr.luma_factor = 120; // 100=normal, >100=brighter, <100=darker4.4 Scale Configuration
xmedia_vgs_scale_attr_t scale_attr;
scale_attr.enable = XMEDIA_TRUE;
scale_attr.dst_width = 640;
scale_attr.dst_height = 480;4.5 Rotate Configuration
xmedia_vgs_rotate_attr_t rotate_attr;
rotate_attr.enable = XMEDIA_TRUE;
rotate_attr.rotate = VGS_ROTATE_90; // 90/180/270 degrees5 Troubleshooting
| Problem | Possible cause | Solution |
|---|---|---|
| OSD not displayed | OSD misconfigured | Check the OSD position and color settings |
| Wrong cover region | Cover coordinates outside the picture | Check that the cover coordinates are in a valid range |
| Picture too bright/dark | Inappropriate luma value | Adjust the luma value to around 100 |
| Distorted scaling | Mismatched aspect ratio | Keep the target aspect ratio the same as the source |
