The OpenVX Specification  dba1aa3

Detailed Description

Allows Clients to receive a callback after a specific node has completed execution.

Callbacks are not guaranteed to be called immediately after the Node completes. Callbacks are intended to be used to create simple early exit conditions for Vision graphs using vx_action_e return values. An example of setting up a callback can be seen below:

vx_graph graph = vxCreateGraph(context);
status = vxGetStatus((vx_reference)graph);
if (status == VX_SUCCESS) {
vx_uint8 lmin = 0, lmax = 0;
vx_uint32 minCount = 0, maxCount = 0;
vx_scalar scalars[] = {
vxCreateScalar(context, VX_TYPE_UINT8, &lmin),
vxCreateScalar(context, VX_TYPE_UINT8, &lmax),
vxCreateScalar(context, VX_TYPE_UINT32, &minCount),
vxCreateScalar(context, VX_TYPE_UINT32, &maxCount),
};
vx_array arrays[] = {
};
vx_node nodes[] = {
vxMinMaxLocNode(graph, input, scalars[0], scalars[1], arrays[0], arrays[1], scalars[2], scalars[3]),
};
status = vxAssignNodeCallback(nodes[0], &analyze_brightness);
// do other
}

Once the graph has been initialized and the callback has been installed then the callback itself will be called during graph execution.

#define MY_DESIRED_THRESHOLD (10)
vx_action VX_CALLBACK analyze_brightness(vx_node node) {
// extract the max value
vx_parameter pmax = vxGetParameterByIndex(node, 2); // Max Value
if (pmax) {
vx_scalar smax = 0;
vxQueryParameter(pmax, VX_PARAMETER_REF, &smax, sizeof(smax));
if (smax) {
vx_uint8 value = 0u;
if (value >= MY_DESIRED_THRESHOLD) {
}
}
}
return action;
}
Warning
This should be used with extreme caution as it can ruin optimizations in the power/performance efficiency of a graph.

The callback must return a vx_action code indicating how the graph processing should proceed.

msc_node_callback
Node Callback Sequence

Typedefs

typedef vx_enum vx_action
 The formal typedef of the response from the callback. More...
 
typedef vx_action(* vx_nodecomplete_f) (vx_node node)
 A callback to the client after a particular node has completed. More...
 

Enumerations

enum  vx_action_e {
  VX_ACTION_CONTINUE = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_ACTION << 12)) + 0x0,
  VX_ACTION_ABANDON = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_ACTION << 12)) + 0x1
}
 A return code enumeration from a vx_nodecomplete_f during execution. More...
 

Functions

vx_status VX_API_CALL vxAssignNodeCallback (vx_node node, vx_nodecomplete_f callback)
 Assigns a callback to a node. If a callback already exists in this node, this function must return an error and the user may clear the callback by passing a NULL pointer as the callback. More...
 
vx_nodecomplete_f VX_API_CALL vxRetrieveNodeCallback (vx_node node)
 Retrieves the current node callback function pointer set on the node. More...
 

Typedef Documentation

typedef vx_enum vx_action

The formal typedef of the response from the callback.

See also
vx_action_e

Definition at line 451 of file vx_types.h.

typedef vx_action( * vx_nodecomplete_f) (vx_node node)

A callback to the client after a particular node has completed.

See also
vx_action
vxAssignNodeCallback
Parameters
[in]nodeThe node to which the callback was attached.
Returns
An action code from vx_action_e.

Definition at line 460 of file vx_types.h.

Enumeration Type Documentation

A return code enumeration from a vx_nodecomplete_f during execution.

See also
vxAssignNodeCallback
Enumerator
VX_ACTION_CONTINUE 

Continue executing the graph with no changes.

VX_ACTION_ABANDON 

Stop executing the graph.

Definition at line 601 of file vx_types.h.

Function Documentation

vx_status VX_API_CALL vxAssignNodeCallback ( vx_node  node,
vx_nodecomplete_f  callback 
)

Assigns a callback to a node. If a callback already exists in this node, this function must return an error and the user may clear the callback by passing a NULL pointer as the callback.

Parameters
[in]nodeThe reference to the node.
[in]callbackThe callback to associate with completion of this specific node.
Warning
This must be used with extreme caution as it can ruin optimizations in the power/performance efficiency of a graph.
Returns
A vx_status_e enumeration.
Return values
VX_SUCCESSCallback assigned; any other value indicates failure.
VX_ERROR_INVALID_REFERENCEnode is not a valid vx_node reference.
vx_nodecomplete_f VX_API_CALL vxRetrieveNodeCallback ( vx_node  node)

Retrieves the current node callback function pointer set on the node.

Parameters
[in]nodeThe reference to the vx_node object.
Returns
vx_nodecomplete_f The pointer to the callback function.
Return values
NULLNo callback is set.
*The node callback function.