08 Region Overlay Application
This chapter describes the GK7206 region overlay application example — sample_region. The application demonstrates overlaying OSD (overlay), cover, mosaic, and corner-rect (corner mark) elements on VPSS/VO/VENC.
The application source code is located in the SDK directory sample/region/, and serves as a reference template for developing video-overlay-related applications.
1 Application Overview
1.1 Features
- Multiple overlay targets: VPSS, VO, VENC
- Multiple overlay types: OVERLAYEX (character overlay), COVEREX (cover), MOSAICEX (mosaic), CORNER RECTEX (corner mark)
- Flexible configuration: supports various resolution and position configurations
1.2 Technical Parameters
| Parameter | Value |
|---|---|
index | 0~10 (see table below) |
Dependencies | index 0~3 requires VPSS (sensor), 4~6 requires VO (panel), 7~10 requires VENC |
1.3 Test Case List
| index | Target | index | Target |
|---|---|---|---|
| 0 | VPSS OVERLAYEX | 6 | VO CORNER RECTEX |
| 1 | VPSS COVEREX | 7 | VENC OVERLAY |
| 2 | VPSS MOSAICEX | 8 | VENC COVER |
| 3 | VPSS CORNER RECTEX | 9 | VENC MOSAIC |
| 4 | VO OVERLAYEX | 10 | VENC CORNER RECT |
| 5 | VO COVEREX |
1.4 Directory Structure
sample/region/
├── Makefile # Build script
└── sample_region.c # Main program2 Build and Deployment
2.1 Build the Application
# Enter the sample directory
cd <SDK_PATH>/sample
# Build the region sample
make -C region clean && make -C region2.2 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/region/sample_region root@<board IP>:/sd_card/2.3 Run the Application
# Add execute permission
chmod +x /sd_card/sample_region
# Enter the SD card directory
cd /sd_card
# Run (index 7: VENC OSD; you can pull the RTSP stream to view it)
./sample_region 7
# Exit
Press e + Enter2.4 Expected Output
After a successful run (index 7), the terminal prints output similar to the following:
sample_region running
region test index: 7
target: VENC
type: OVERLAY
...
rtsp://192.168.1.100:554/livestream/0After pulling the stream, you can see the overlaid OSD text on the picture.
3 Internal Execution Logic
3.1 Application Architecture
The application adopts the following architecture:
Sensor → VI → VPSS → REGION → VENC → RTSP streaming3.2 REGION Initialization Flow
// Step 1: system initialization
sample_comm_sys_init(&sys_config);
// Step 2: ISP initialization
sample_comm_isp_init();
// Step 3: VI start
sample_comm_vi_start(...);
// Step 4: VPSS start
sample_comm_vpss_start(...);
// Step 5: VENC start
sample_comm_venc_start(...);
// Step 6: REGION initialization
xmedia_region_init();
// Step 7: configure REGION tasks
switch(index) {
case 7: // VENC OVERLAY
xmedia_region_attach_venc_chn(venc_chn, ®ion_attr);
break;
// ... other cases
}
// Step 8: bind modules
xmedia_bind_vpss_to_venc(...);4 Key Programming Points
4.1 OVERLAYEX Configuration
xmedia_region_attr_t region_attr;
region_attr.type = XMEDIA_REGION_TYPE_OVERLAYEX;
region_attr.rect.x = 10;
region_attr.rect.y = 10;
region_attr.rect.width = 200;
region_attr.rect.height = 30;
region_attr.color = 0xFFFFFF; // white
strcpy(region_attr.text, "Hello Region");4.2 COVEREX Configuration
region_attr.type = XMEDIA_REGION_TYPE_COVEREX;
region_attr.rect.x = 100;
region_attr.rect.y = 100;
region_attr.rect.width = 200;
region_attr.rect.height = 200;
region_attr.color = 0xFF0000; // red4.3 MOSAICEX Configuration
region_attr.type = XMEDIA_REGION_TYPE_MOSAICEX;
region_attr.rect.x = 150;
region_attr.rect.y = 150;
region_attr.rect.width = 100;
region_attr.rect.height = 100;
region_attr.mosaic_blk_size = 16; // mosaic block size5 Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| Overlay not displayed | REGION misconfiguration | Check the REGION position and color settings |
| VENC overlay fails | VENC channel not set up | Check whether the VENC channel is initialized |
| VO overlay fails | No display device | Use VENC overlay or connect a display device |
