Video Data Obtaining + VPSS Video Processing
The VPSS module must work with the VI module. This section describes the API call sequence and precautions.
Figure 1 API call sequence of VPSS


The API call sequence is as follows:
- Initialize.
- Initialize the media system by calling hi_mpi_sys_init.
- Call hi_mpi_rgn_create to create a region.
- As the bound party, the VPSS module passively receives and processes video stream data. Therefore, you need to call the hi_mpi_sys_bind interface to bind the planned VI channel to the VPSS group.
- Create a VPSS group by calling hi_mpi_vpss_create_grp as the bound party of hi_mpi_sys_bind.
- Enable the VPSS function as required.
- If group cropping is required, call the hi_mpi_vpss_set_grp_crop interface to set the cropping configuration.
- To enable 3DNR, you can enable the NR switch and configure the NR attributes by calling the hi_mpi_vpss_create_grp interface, or set the advanced NR parameters by calling the hi_mpi_vpss_set_grp_param interface.
- If fisheye correction needs to be enabled and the length map function (LMF) parameter function is enabled by using the hi_fisheye_attr attribute of the hi_mpi_vi_set_chn_fisheye interface, you must call the hi_mpi_vpss_set_grp_fisheye_cfg interface to set the LMF parameter.
- Enable a VPSS group by calling hi_mpi_vpss_start_grp.
- Call the hi_mpi_vpss_set_chn_attr interface to set the channel attributes. The output resolution of the channel can be different from the resolution of the input source. If they are different, scaling is automatically enabled. The scaling capability varies according to the channel.
- To enable fisheye distortion correction, call the hi_mpi_vi_set_chn_fisheye API to set the fisheye correction parameters.
- Start the VPSS channel by calling hi_mpi_vpss_enable_chn.
- Call the hi_mpi_rgn_attach_to_chn interface to overlay the region on the VPSS channel.
- Collect and process data.
- Use the MIPI RX ioctl command words to initialize the MIPI/sensor hardware interconnection information. For details, see Initializing the MIPI/Sensor Hardware Interconnection Information.
- Call the VI functional API to initialize the VI module. For details, see Initializing the VI Module.
- Call the ISP system control API to initialize and run the ISP module. For details, see Initializing and Running the ISP Module.
- The system automatically transfers the pictures processed by the VI channel to the VPSS based on the binding policy configured by calling hi_mpi_sys_bind.
- The system automatically performs cropping, 3DNR, fisheye correction, and resizing based on the VPSS parameters.
- Update and modify region information as required.
- Set the channel display attributes of a region.
- Obtain the current channel display attributes of a region by calling hi_mpi_rgn_get_display_attr.
- Set the channel display attributes of a region by calling hi_mpi_rgn_set_display_attr.
- Set the canvas information of the region.
- Invoke the hi_mpi_rgn_get_canvas_info interface to obtain the canvas information of the current region.
- Invoke the hi_mpi_rgn_update_canvas interface to update the canvas information.
- Set the channel display attributes of a region.
- Obtain the processing result data.
In this case, you can call the hi_mpi_vpss_get_chn_fd interface to obtain the handle of the specified VPSS channel and wait for the VPSS processing result by calling the select/epoll interface. After the VPSS processing is complete, the select/epoll wait is automatically woken up. In this case, you can call hi_mpi_vpss_get_chn_frame to obtain the image data processed by the VPSS for subsequent processing, and then call hi_mpi_vpss_release_chn_frame to release a frame of channel image.
- Free VI and VPSS initialization resources.
- Call the ISP functional API to free ISP module resources. For details, see Releasing the Resources of the ISP Module.
- Call the VI functional API to free VI module resources. For details, see Releasing VI Resources.
- Use the MIPI RX ioctl command words to exit the MIPI/sensor hardware. For details, see Exiting the MIPI/Sensor Hardware.
- Call the hi_mpi_rgn_detach_from_chn interface to delete a specified region from a channel.
- Disable the VPSS channel by calling hi_mpi_vpss_disable_chn.
- Stop the VPSS group by calling hi_mpi_vpss_stop_grp.
- Destroy the VPSS group by calling hi_mpi_vpss_destroy_grp.
- Unbind the VI module from the VPSS module by calling hi_mpi_sys_unbind.
- Call the hi_mpi_rgn_destroy interface to destroy the region.
- Invoke the hi_mpi_sys_exit interface to exit the media system.
Parent topic: Video Data Obtaining and Processing (Camera Scenario)