1 # Copyright (c) 2017-2019 NVIDIA CORPORATION. All rights reserved.
3 @page object_usecase1 Object Detector Workflow
4 @note SW Release Applicability: This tutorial is applicable to modules in **NVIDIA DRIVE Software** releases.
6 This code snippet shows how the Object Detector module is typically used. Note that error handling is left out for clarity.
8 Initialize ObjectDetector parameters with default values.
11 dwObjectDetectorParams detectorParams{};
12 dwObjectDetector_initDefaultParams(&detectorParams);
15 Modify parameters as needed.
18 // Detect objects inside the full image
19 detectorParams.ROIs[0] = {0, 0, imageWidth, imageHeight};
22 Initialize ObjectDetector module from DriveNet.
26 dwObjectDetector_initializeFromDriveNet(&detectorHandle, &detectorParameters, driveNetHandle, contextHandle);
29 Allocate a container for storing the detections. The container needs to have enough space for all
30 detections of all classes known to the object detector.
33 dwObjectArray detections = {};
34 dwObjectArray_create(&detections, 200, DW_OBJECT_TYPE_CAMERA);
37 Run all object detector processing steps on the given image.
40 dwObjectDetector_detectObjects(&detections, rcbImage, detectorHandle);
43 Access the bounding boxes and classes of the detections.
46 dwObjectCamera* array = static_cast<dwObjectCamera*>(detections.objects);
47 for (uint32_t i = 0; i < detections.count; ++i)
49 // dwRectf boundingBox = array[i].box2D;
50 // dwObjectClass objectClass = array[i].details.objectClass;
54 To check whether depth values for the objects detected from DriveNet are available.
56 bool isObjectDepthEnabled;
57 dwObjectDetector_isObjectDepthEnabled(&isObjectDepthEnabled, detectorHandle);
60 Finally, free memory allocated by the array and the detector.
64 dwObjectArray_destroy(&detections);
65 dwObjectDetector_release(detectorHandle);
69 For more details see @ref dwx_drivenet_sample.