DriveWorks SDK Reference
5.8.83 Release
For Test and Development only

Connected Components Workflow

Workflow

The workflow of the connected components module is:

  • Create connected components handle.
dwImageProperties inputProps{};
inputProps.width = width;
inputProps.height = height;
inputProps.type = DW_IMAGE_CUDA;
inputProps.format = DW_IMAGE_FORMAT_R_UINT8;
dwConnectedComponents_initialize(&ccl, &inputProps, cc);
struct dwConnectedComponentsObject * dwConnectedComponentsHandle_t
A pointer to the opaque handle for Connected Components.
DW_API_PUBLIC dwStatus dwConnectedComponents_initialize(dwConnectedComponentsHandle_t *ccl, const dwImageProperties *inputDesc, dwContextHandle_t context)
Initializes connected components.
uint32_t width
Specifies the width of the image in pixels.
Definition: Image.h:401
@ DW_IMAGE_CUDA
Definition: Image.h:100
@ DW_IMAGE_FORMAT_R_UINT8
Definition: Image.h:130
Defines the properties of the image.
Definition: Image.h:397
  • Create input and output images.
dwImageHandle_t inputImageHandle;
dwImage_create(&inputImage, inputProps, cc);
// fill input image with actual data
// ...
dwImageProperties outputProps{};
outputProps.width = width;
outputProps.height = height;
outputProps.type = DW_IMAGE_CUDA;
outputProps.format = DW_IMAGE_FORMAT_RGBA_UINT8;
dwImageHandle labelsImageHandle;
dwImage_create(&labelsImageHandle, outputProps, cc);
struct dwImageObject * dwImageHandle_t
Definition: Image.h:110
DW_API_PUBLIC dwStatus dwImage_create(dwImageHandle_t *const image, dwImageProperties properties, dwContextHandle_t const ctx)
Creates and allocates resources for a dwImageHandle_t based on the properties passed as input.
@ DW_IMAGE_FORMAT_RGBA_UINT8
Definition: Image.h:152
  • Perform labeling.
dwImageCUDA* inputImage = nullptr;
dwImage_getCUDA(&inputImage, inputImageHandle);
dwImageCUDA* labelImage = nullptr;
dwImage_getCUDA(&labelImage, labelsImageHandle);
dwConnectedComponents_bindOutput(labelImage, ccl);
DW_API_PUBLIC dwStatus dwConnectedComponents_bindInput(const dwImageCUDA *image, dwConnectedComponentsHandle_t ccl)
Specifies input image to be processed.
DW_API_PUBLIC dwStatus dwConnectedComponents_process(dwConnectedComponentsHandle_t ccl)
Performs image labeling.
DW_API_PUBLIC dwStatus dwConnectedComponents_setThreshold(uint8_t threshold, dwConnectedComponentsHandle_t ccl)
Specifies threshold to binarize input image.
DW_API_PUBLIC dwStatus dwImage_getCUDA(dwImageCUDA **const imageCUDA, dwImageHandle_t const image)
Retrieves the dwImageCUDA of a dwImageHandle_t.
Defines a CUDA image.
Definition: Image.h:427

dwConnectedComponents_setThreshold is a function to define threshold for image binarization. Pixels which values are below the specified threshold are considered to be background pixels.

For a demonstration of this workflow, see Connected Components Sample.