Apologies for the earlier misinformation. To obtain tensor output data for a node in OpenVX, you should use vxQueryParameter to retrieve the tensor object associated with the output parameter. Here's how you can do it:
- Create an OpenVX context and load the necessary OpenVX modules.
vx_context context = vxCreateContext();
vxLoadKernels(context, "openvx_kernels");
- Create the required OpenVX graph and add the necessary nodes.
vx_graph graph = vxCreateGraph(context);
// Create and add nodes to the graph
vx_node node = vxCreateNode(graph, ...);
...
vxAddParameterToGraph(graph, input_tensor);
vxAddParameterToGraph(graph, output_tensor);
- Verify the graph with
vxVerifyGraph.
vx_status status = vxVerifyGraph(graph);
if (status == VX_SUCCESS) {
// Graph is verified successfully
}
- Process the graph using
vxProcessGraph.
status = vxProcessGraph(graph);
if (status == VX_SUCCESS) {
// Graph processing completed successfully
}
- Use
vxQueryParameter to obtain the tensor object associated with the output parameter.
vxQueryParameter(node, VX_PARAMETER_NUM, &output_parameter_index, sizeof(output_parameter_index));
vx_parameter output_parameter = vxGetParameterByIndex(node, output_parameter_index);
vx_enum parameter_type;
vxQueryParameter(output_parameter, VX_PARAMETER_TYPE, ¶meter_type, sizeof(parameter_type));
if (parameter_type == VX_PARAMETER_TYPE_IMAGE) {
// Handle image output parameter
vx_image output_image;
vxQueryParameter(output_parameter, VX_PARAMETER_REF, &output_image, sizeof(output_image));
// Process the output image as needed
}
else if (parameter_type == VX_PARAMETER_TYPE_TENSOR) {
// Handle tensor output parameter
vx_tensor output_tensor;
vxQueryParameter(output_parameter, VX_PARAMETER_REF, &output_tensor, sizeof(output_tensor));
// Map and access the tensor data
vx_map_id map_id;
vx_uint8* ptr;
vx_size stride;
status = vxMapTensorPatch(output_tensor, ..., &map_id, &stride, (void**)&ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST);
if (status == VX_SUCCESS) {
// Access the tensor data using the ptr pointer
}
// Unmap tensor patch after accessing the data
status = vxUnmapTensorPatch(output_tensor, map_id);
}
// Release the output parameter
vxReleaseParameter(&output_parameter);
Remember to release the allocated resources after using them:
vxReleaseContext(&context);
vxReleaseGraph(&graph);
vxReleaseNode(&node);
vxReleaseTensor(&output_tensor); // Release the output tensor if needed
...
This code snippet demonstrates obtaining tensor output data using vxQueryParameter based on the parameter type. Adjust the code according to your specific implementation and node requirements.