This code snippet demonstrates the how the DNN module with DNN Tensors is typically used. Note that error handling is left out for clarity.
Initialize network from file.
If the model has been generated on DLA using --useDLA
option with tensorrt_optimization tool, the processor type should be either DW_PROCESSOR_TYPE_DLA_0
or DW_PROCESSOR_TYPE_DLA_1
depending on which DLA engine the inference should take place. Otherwise, the processor type should always be DW_PROCESSOR_TYPE_GPU
.
contextHandle
is assumed to be a previously initialized dwContextHandle_t
.
Check that the loaded network has the expected number of inputs and outputs.
Ask the DNN about the order of the input and output blobs. The network is assumed to contain the input blob "data_in" and output blobs "data_out1" and "data_out2".
Initialize tensors.
Convert DNN input from image to tensor, then perform DNN inference and stream results back. All operations are performed asynchronously with the host code.
Finally, free previously allocated memory.
For more information see: