3.5. sample_osd User Guide

3.5.1. Function Overview

The sample_osd initializes the VSE module, configures input and output channel parameters, and achieves OSD fill-color, line drawing, text rendering, and mosaic functions by configuring operation regions (Region) and overlaying them onto the image.

3.5.1.1. Software Architecture Description

image-20241225-160821

3.5.1.2. Code Location and Directory Structure

  • Code location: app/samples/platform_samples/sample_osd

  • Directory structure:

sample_osd/
├── Makefile
└── sample_osd.c

3.5.1.3. API Flow Description

image-20250728-163105

3.5.2. Compilation and Deployment

3.5.2.1. Compilation

  • Enter the sample_osd directory and run make to compile

  • The output artifact is sample_osd located in the source directory

  • For detailed compilation methods, refer to the Compilation Methods section

3.5.2.2. Program Deployment

After flashing the system software image, the executable file of this sample is located on the board at: /app/platform_samples/sample_osd.

The required configuration files are located on the board at: /app/platform_samples/sample_codec.

3.5.3. Execution

3.5.3.1. Execution Method

Running the program directly with ./sample_osd displays help information:

3.5.3.2. Program Parameter Options

./sample_osd
Usage: sample_osd [OPTIONS]
Options:
-i, --input_file FILE           Specify the input file
-w, --input_width WIDTH         Specify the input width
-h, --input_height HEIGHT       Specify the input height
-m, --work_mode                 1.cover_test 2.draw_word_test 3.draw_line_test 4.mosaic_test
-f, --feedback                  Specify feedback mode

Options:

  • -i, --input_file FILE: Specifies the input file; only NV12 format images are supported

  • -w, --input_width WIDTH: Specifies the input width

  • -h, --input_height HEIGHT: Specifies the input height

  • -m, --work_mode: Specifies the working mode (1: fill color test 2: text drawing test 3: line drawing test 4: mosaic test)

    • -m 1: Test OSD fill-color function

    • -m 2: Test OSD text rendering function

    • -m 3: Test OSD line drawing function

    • -m 4: Test OSD mosaic function

  • -f, --feedback: Use feedback mode to create data stream

3.5.3.3. Execution Results

3.5.4. Execution Result Description

3.5.4.1. Fill-Color Function

Fills a specified region on an NV12-format YUV image with a specified color block.

Execution command:

./sample_osd -i 1280x720_NV12.yuv  -w 1280 -h 720 -m 1

Log output:

Using input file:1280x720_NV12.yuv, input:1280x720
(read_yuvv_nv12_file):file read(1280x720_NV12.yuv), y-size(921600)
ichn input width = 1280
ichn input input_height = 720
hbn_vnode_set_ochn_attr: 0, 1280x720
hbn_vnode_set_ochn_attr: 1, 1280x720
hbn_vnode_set_ochn_attr: 2, 1280x720
hbn_vnode_set_ochn_attr: 3, 1280x720
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 2560x1440
... (omitted) ...
Dump image to file(./vse_output_nv12_chn0_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn1_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn2_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn3_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn4_672x672_stride_672.yuv), size(451584) + size1(225792) succeeded
Dump image to file(./vse_output_nv12_chn5_2560x1440_stride_2560.yuv), size(11796480) + size1(5898240) succeeded

The color fill operation is applied to all six channels of the VSE. After execution, six processed NV12-format YUV images are generated, as shown below:

image-20240624221729659

3.5.4.2. Text Rendering

Draws text in a specified region on an NV12-format YUV image.

Execution command:

./sample_osd -i 1280x720_NV12.yuv  -w 1280 -h 720 -m 2

Log output:

Using input file:1280x720_NV12.yuv, input:1280x720
(read_yuvv_nv12_file):file read(1280x720_NV12.yuv), y-size(921600)
ichn input width = 1280
ichn input input_height = 720
hbn_vnode_set_ochn_attr: 0, 1280x720
hbn_vnode_set_ochn_attr: 1, 1280x720
hbn_vnode_set_ochn_attr: 2, 1280x720
hbn_vnode_set_ochn_attr: 3, 1280x720
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 2560x1440
... (omitted) ...
Dump image to file(./vse_output_nv12_chn0_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn1_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn2_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn3_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn4_672x672_stride_672.yuv), size(451584) + size1(225792) succeeded
Dump image to file(./vse_output_nv12_chn5_2560x1440_stride_2560.yuv), size(11796480) + size1(5898240) succeeded

The current system date and time are added to the images from all six VSE channels. After execution, six processed NV12-format YUV images are generated, as shown below:

image-20240624221519048

3.5.4.3. Line Drawing

Draws lines in a specified region on an NV12-format YUV image.

Execution command:

./sample_osd -i 1280x720_NV12.yuv  -w 1280 -h 720 -m 3

Log output:

Using input file:1280x720_NV12.yuv, input:1280x720
(read_yuvv_nv12_file):file read(1280x720_NV12.yuv), y-size(921600)
ichn input width = 1280
ichn input input_height = 720
hbn_vnode_set_ochn_attr: 0, 1280x720
hbn_vnode_set_ochn_attr: 1, 1280x720
hbn_vnode_set_ochn_attr: 2, 1280x720
hbn_vnode_set_ochn_attr: 3, 1280x720
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 2560x1440
... (omitted) ...
Dump image to file(./vse_output_nv12_chn0_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn1_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn2_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn3_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn4_672x672_stride_672.yuv), size(451584) + size1(225792) succeeded
Dump image to file(./vse_output_nv12_chn5_2560x1440_stride_2560.yuv), size(11796480) + size1(5898240) succeeded

Four lines forming a polygon are drawn on the images from all six VSE channels. After execution, six processed NV12-format YUV images are generated, as shown below:

image-20240624221619939

3.5.4.4. Mosaic Effect

Applies a mosaic effect to a specified region on an NV12-format YUV image.

Execution command:

./sample_osd -i 1280x720_NV12.yuv  -w 1280 -h 720 -m 4

Log output:

VSE vnode work mode: vflow
Using input file:1280x720_NV12.yuv, input:1280x720
(read_yuvv_nv12_file):file read(1280x720_NV12.yuv), y-size(921600)
ichn input width = 1280
ichn input input_height = 720
hbn_vnode_set_ochn_attr: 0, 1280x720
hbn_vnode_set_ochn_attr: 1, 1280x720
hbn_vnode_set_ochn_attr: 2, 1280x720
hbn_vnode_set_ochn_attr: 3, 1280x720
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 2560x1440
... (omitted) ...
Dump image to file(./vse_output_nv12_chn0_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn1_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn2_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn3_1280x720_stride_1280.yuv), size(921600) + size1(460800) succeeded
Dump image to file(./vse_output_nv12_chn4_672x672_stride_672.yuv), size(451584) + size1(225792) succeeded
Dump image to file(./vse_output_nv12_chn5_2560x1440_stride_2560.yuv), size(3686400) + size1(1843200) succeeded

A 400×200 horizontal mosaic area is applied to the images from all six VSE channels. After execution, six processed NV12-format YUV images are generated, as shown below:

image-20250728-162049