VisionWorks Toolkit Reference

December 18, 2015 | 1.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
5. User Custom Node Factory

This section illustrates the implementation of the user custom node factory.

Creating a node factory function for each of the registered custom kernels is good programming practice since it allows the application to create a custom node similar to the way it creates standard nodes.

The best convention for a custom node factory function is to have a Object: Graph as the first argument, followed by the node parameters in the order they were declared in the custom kernel. It gives for the example discussed in this tutorial the following prototype:

vx_node keypointArraySortNode(vx_graph graph, vx_array src, vx_array dst, vx_scalar use_strength)

The purpose of the node factory function is to create a node object and return its reference; this is done in 3 steps:

5.1. Get kernel object by its identifier

vx_kernel kernel = vxGetKernelByEnum(context, USER_KERNEL_KEYPOINT_ARRAY_SORT);

5.2. Create node object from the kernel object

node = vxCreateGenericNode(graph, kernel);
vxReleaseKernel(&kernel);

5.3. Set node parameters

The Full Code for the Node Factory Function

vx_node keypointArraySortNode(vx_graph graph, vx_array src, vx_array dst, vx_scalar use_strength)
{
vx_node node = NULL;
vx_kernel kernel = vxGetKernelByEnum(context, USER_KERNEL_KEYPOINT_ARRAY_SORT);
{
node = vxCreateGenericNode(graph, kernel);
vxReleaseKernel(&kernel);
{
vxSetParameterByIndex(node, 2, (vx_reference)use_strength);
}
}
return node;
}