VisionWorks Toolkit Reference

April 8, 2016 | 1.4 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Single Image Processing with Immediate Mode

This tutorial demonstrates single image processing with immediate mode.

The tutorial uses the following pipeline as an example:

(source image) -> [Median 3x3] -> [Equalize Hist] -> [Canny Edge Detector] -> (edges)

VisionWorks has two modes for vision primitive execution : immediate mode and graph mode. In immediate mode, primitives are executed directly by calling a function (like in OpenCV or NPP). The mode is useful for single image processing.

First, the source image is loaded from a file using NVXIO library. The NVXIO library must be initialized prior to this call.

vx_image source = nvxio::loadImageFromFile(context, sourceUri, VX_DF_IMAGE_U8);

Second, the output edges image is created, as well as an dditional vx_threshold object that is used for CannyEdgeDetector primitive.

vx_uint32 width, height;
vxQueryImage(source, VX_IMAGE_ATTRIBUTE_WIDTH, &width, sizeof(width));
vxQueryImage(source, VX_IMAGE_ATTRIBUTE_HEIGHT, &height, sizeof(height));
vx_image edges = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
vx_int32 lowerThresh = 230, upperThresh = 250;
&lowerThresh, sizeof(lowerThresh));
&upperThresh, sizeof(upperThresh));

Finally, the VisionWorks primitives are called in immediate mode. Note that intermediate data objects are created as normal images.

vx_image filtered = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
vx_image equalized = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
vxuMedian3x3(context, source, filtered);
vxuEqualizeHist(context, filtered, equalized);
vxuCannyEdgeDetector(context, equalized, hyst, 3, VX_NORM_L1, edges);
vxReleaseImage(&filtered);
vxReleaseImage(&equalized);