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:

  1. Initialize.
    1. Call hi_mpi_sys_init to initialize the media system.
    2. Call hi_mpi_rgn_create to create a region.
    3. The VPSS module can only act as the bound party to passively receive and process video stream data. Therefore, bind a planned VI channel to a VPSS group by calling hi_mpi_sys_bind.
    4. Call hi_mpi_vpss_create_grp to create a VPSS group as the bound party of hi_mpi_sys_bind.
    5. Enable the VPSS function as required.
    6. Call hi_mpi_vpss_start_grp to enable the VPSS group.
    7. Call hi_mpi_vpss_set_chn_attr to set the channel attributes. The channel output resolution can be different from the input resolution. When they are different, resizing is automatically enabled. The resizing capability varies according to the channel.
    8. To enable fisheye distortion correction, call hi_mpi_vi_set_chn_fisheye to set fisheye distortion correction parameters.
    9. Call hi_mpi_vpss_enable_chn to enable the VPSS channel.
    10. Call hi_mpi_rgn_attach_to_chn to overlay the region on the VPSS channel.
  2. Collect and process data.
    1. 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.
    2. Call the VI functional API to initialize the VI module. For details, see Initializing the VI Module.
    3. Call the ISP system control API to initialize and run the ISP module. For details, see Initializing and Running the ISP Module.
    4. The system automatically transfers the images processed by the VI channel to the VPSS based on the binding policy configured by calling hi_mpi_sys_bind.
    5. The system automatically performs cropping, 3DNR, fisheye correction, and resizing based on the VPSS parameters.
    6. Update and modify region information as required.
  3. Obtain the processing result data.

    In this case, obtain the handle to a specified VPSS channel by calling hi_mpi_vpss_get_chn_fd, and wait for the VPSS processing result by calling select/epoll. 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 free a frame of channel image.

  4. Free VI and VPSS initialization resources.
    1. Call the ISP functional API to free ISP module resources. For details, see Releasing the Resources of the ISP Module.
    2. Call the VI functional API to free VI module resources. For details, see Releasing VI Resources.
    3. Use the MIPI RX ioctl command words to exit the MIPI/sensor hardware. For details, see Exiting the MIPI/Sensor Hardware.
    4. Call hi_mpi_rgn_detach_from_chn to delete a specified region from the channel.
    5. Call hi_mpi_vpss_disable_chn to disable the VPSS channel.
    6. Call hi_mpi_vpss_stop_grp to stop the VPSS group.
    7. Call hi_mpi_vpss_destroy_grp to destroy the VPSS group.
    8. Call hi_mpi_sys_unbind to unbind VI from VPSS.
    9. Call hi_mpi_rgn_destroy to destroy the region.
    10. Call hi_mpi_sys_exit to exit the media system.