The following code snippet shows the general structure of a program that uses the free space detector to detect drive-able free space from a single camera. Note that error handling is left out for clarity.
Free space detector module initialization takes an OpenRoadNet module handle as input:
With the initialized OpenRoadNet module handle, free space module is initialized by:
where dwFreespaceDetectorInitParams stores the initialization parameters used to initialize a free space detector module. Parameters such as the handle to a calibrated camera and cuda stream should be assigned here. Set calibrated camera handle to nullptr, to get free space boundary only in image space. You can also provide the runtime parameters via dwFreespaceDetectorRuntimeParams
altogether by dwFreespaceDetector_setRuntimeParams() or individual set parameter functions described below.
To perform free space detection on a batch of images, you will need to set batchSize in dwOpenRoadNetParams
to one of the dwOpenRoadNetBatchSize
enum values before dwOpenRoadNet_initialize(). Next, the input image array needs to be bound by:
and output dwFreeSpaceDetection array is bound by:
where frameIdx
corresponds to the frame index of the boundary to be bound.
To get free space boundary detected in top-view vehicle coordinate system, camera intrinsics can be set via the module initialization call. Note that dwFreespaceDetector_setCameraHandle(...) is deprecated. To set camera extrinsics:
Free space detector allows user to set detection Region of Interest (ROI) and how much each detected boundary is being spatially and/or temporally smoothed.
To set detection ROI in input image coordinates:
To spatially smooth each detected free space boundary:
To temporally smooth each detected free space boundary:
To set all the aforementioned runtime parameters at once:
For more details, please refer to API header documentation.
After module initialization and detector parameter setup, there are 2 options can be used to infer free space boundary on GPU and post-process on CPU: For batch or single image free space boundary computation, use the following 3-stage process calls in the order of:
The process calls assume that input image array and output dwFreeSpaceDetection array are bound during initialization. Then, the result can be accessed from the output dwFreeSpaceDetection array.
Alternatively, to process only one image at a time, use:
instead. Input and output bindings are not required here.
Note that the following APIs are already deprecated and will be removed in the next release:
To release the free space module, the module itself needs to be released first by:
then the OpenRoadNet module:
For more detailed workflow, please refer to the free space sample: Freespace Detection Sample (OpenRoadNet)