• 04/03/2020
  • Public Content
Contents

Example of OpenCV Processing of the OpenVX* Image

Often, the standard OpenVX* kernels and extensions are not enough for implementing particular computer vision pipeline. Similarly the
vx_image
can be accessed with OpenCV, using the same
vxMapImagePatch/vxUnmapImagePatch
functions (see the Example Interoperability with OpenCV section).
void callOpenCVGaussianBlur(vx_image input, vx_image output) { vx_uint32 width = 0, height = 0; vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); vx_rectangle_t rect = { 0u, 0u, width, height }; vx_imagepatch_addressing_t input_addr = {}; void *input_ptr = nullptr; vx_map_id map_id_in; vxMapImagePatch(input, &rect, 0, &map_id_in, &input_addr, &input_ptr, VX_READ_ONLY); vx_imagepatch_addressing_t output_addr = {}; void *output_ptr = nullptr; vx_map_id map_id_out; vxMapImagePatch(output, &rect, 0, & map_id_out , &output_addr, &output_ptr, VX_WRITE_ONLY); cv::Mat mat_input(input_addr.dim_y * VX_SCALE_UNITY / input_addr.scale_y, input_addr.dim_x * VX_SCALE_UNITY / input_addr.scale_x, CV_8UC1, input_ptr, input_addr.stride_y); cv::Mat mat_output(output_addr.dim_y * VX_SCALE_UNITY / output_addr.scale_y, output_addr.dim_x * VX_SCALE_UNITY / output_addr.scale_x, CV_8UC1, output_ptr, output_addr.stride_y); cv::GaussianBlur(mat_input, mat_output, cv::Size(5, 5), 1.5); vxUnmapImagePatch(input, map_id_in); }
Also, you can make the function above fully pluggable to OpenVX graphs. Specifically, the OpenVX* supports user-defined functions that are executed as nodes from inside the graph. As detailed in multiple examples (see the OpenVX Sample Applications chapter) in order to define a user kernel, you just need to implement several call-back functions in addition to the execution routine itself.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.