- Note
- SW Release Applicability: This tutorial is applicable to modules in NVIDIA DRIVE Software releases.
The following code snippet shows the general structure of a program that uses path detector to detect drive-able paths from a single camera. Note that error handling is left out for clarity.
Initialize PathNet default parameters and then the module:
dwPathNetParams pathNetParams{};
dwPathNet_initDefaultParams(&pathNetParams));
dwPathNet_initialize(&pathNetHandle, &pathNetParams, sdkHandle));
Initialize Path detector module from initialized PathNet handle without calibrated camera:
dwPathDetector_initializeFromPathNet(&pathDetectorHandle,
pathNetHandle,
cameraWidth,
cameraHeight,
cudaStream,
sdkHandle);
Initialize Path detector module from initialized PathNet handle with calibrated camera:
dwPathDetector_initializeFromPathNet(&pathDetectorHandle,
pathNetHandle,
cameraWidth,
cameraHeight,
calibratedCameraHandle,
tranformationMatrix,
cudaStream,
sdkHandle);
Initialize detector parameters (optional):
dwPathDetector_setTemporalSmoothFactor(temporalSmoothFactor, pathDetectorHandle);
dwRect roi = {...};
dwPathDetector_setDetectionROI(&roi, pathDetectorHandle);
dwStatus dwPathDetector_setComputeCenterRailFrom3D(computeCenterRailFrom3D, pathDetectorHandle);
Detect paths from a video sequence:
while(true)
{
dwPathDetection paths{};
dwPathDetector_processDeviceAsync(frame, pathDetectorHandle);
dwPathDetector_interpretHost(pathDetectorHandle);
dwPathDetector_getPathDetections(&paths, pathDetectorHandle);
}
When finished, release the module handles:
dwPathDetector_release(pathDetectorHandle);
dwPathNet_release(pathNetHandle);
For more detailed workflow, please refer to the path detection sample: Path Perception Sample (PathNet)