This chapter introduces the GK7206 region overlay sample, sample_region. It demonstrates overlay, cover, mosaic, and corner-rectangle features on VPSS, VO, and VENC.
The source lives in sample/region/ in the SDK and serves as a reference template for video overlay work.
| Parameter | Value |
|---|---|
index |
0~10 (see below) |
Dependency |
index 0~3 need VPSS (sensor), 4~6 need VO (panel), 7~10 need VENC |
| 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 |
sample/region/
├── Makefile # build script
└── sample_region.c # main program
# enter the sample directory
cd <SDK_PATH>/sample
# build the region sample
make -C region clean && make -C region
# mount the SD card (recommended)
mkdir -p /sd_card
mount -t vfat /dev/mmcblk1p1 /sd_card
# transfer to the board over SCP
scp sample/region/sample_region root@<board-IP>:/sd_card/
# make it executable
chmod +x /sd_card/sample_region
# enter the SD card directory
cd /sd_card
# run it (index 7: VENC OSD, view it over RTSP)
./sample_region 7
# exit
press e + Enter
After a successful start (index 7), the terminal prints output like this:
sample_region running
region test index: 7
target: VENC
type: OVERLAY
...
rtsp://192.168.1.100:554/livestream/0
After pulling the stream you can see the overlaid OSD text on the image.
This application uses the following architecture:
Sensor -> VI -> VPSS -> REGION -> 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: start VENC
sample_comm_venc_start(...);
// Step 6: REGION initialization
xmedia_region_init();
// Step 7: configure the REGION task
switch(index) {
case 7: // VENC OVERLAY
xmedia_region_attach_venc_chn(venc_chn, ®ion_attr);
break;
// ... other cases
}
// Step 8: bind the modules
xmedia_bind_vpss_to_venc(...);
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");
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; // red
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 size
| Problem | Likely cause | Fix |
|---|---|---|
| Overlay does not appear | Wrong REGION configuration | Check the REGION position and color settings |
| VENC overlay fails | VENC channel not configured | Check that the VENC channel is initialized |
| VO overlay fails | No display device | Use VENC overlay or attach a display |