DriveWorks SDK Reference
3.0.4260 Release
For Test and Development only

perception/object/camera/docs/usecase1.md
Go to the documentation of this file.
1 # Copyright (c) 2017-2019 NVIDIA CORPORATION. All rights reserved.
2 
3 @page object_usecase1 Object Detector Workflow
4 @note SW Release Applicability: This tutorial is applicable to modules in **NVIDIA DRIVE Software** releases.
5 
6 This code snippet shows how the Object Detector module is typically used. Note that error handling is left out for clarity.
7 
8 Initialize ObjectDetector parameters with default values.
9 
10 ```{.cpp}
11  dwObjectDetectorParams detectorParams{};
12  dwObjectDetector_initDefaultParams(&detectorParams);
13 ```
14 
15 Modify parameters as needed.
16 
17 ```{.cpp}
18  // Detect objects inside the full image
19  detectorParams.ROIs[0] = {0, 0, imageWidth, imageHeight};
20 ```
21 
22 Initialize ObjectDetector module from DriveNet.
23 
24 ```{.cpp}
25  initializeDriveNet();
26  dwObjectDetector_initializeFromDriveNet(&detectorHandle, &detectorParameters, driveNetHandle, contextHandle);
27 ```
28 
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.
31 
32 ```{.cpp}
33  dwObjectArray detections = {};
34  dwObjectArray_create(&detections, 200, DW_OBJECT_TYPE_CAMERA);
35 ```
36 
37 Run all object detector processing steps on the given image.
38 
39 ```{.cpp}
40  dwObjectDetector_detectObjects(&detections, rcbImage, detectorHandle);
41 ```
42 
43 Access the bounding boxes and classes of the detections.
44 ```{.cpp}
45 
46  dwObjectCamera* array = static_cast<dwObjectCamera*>(detections.objects);
47  for (uint32_t i = 0; i < detections.count; ++i)
48  {
49  // dwRectf boundingBox = array[i].box2D;
50  // dwObjectClass objectClass = array[i].details.objectClass;
51  }
52 ```
53 
54 To check whether depth values for the objects detected from DriveNet are available.
55 ```{.cpp}
56 bool isObjectDepthEnabled;
57 dwObjectDetector_isObjectDepthEnabled(&isObjectDepthEnabled, detectorHandle);
58 ```
59 
60 Finally, free memory allocated by the array and the detector.
61 
62 ```{.cpp}
63  // Free resources
64  dwObjectArray_destroy(&detections);
65  dwObjectDetector_release(detectorHandle);
66  releaseDriveNet();
67 ```
68 
69 For more details see @ref dwx_drivenet_sample.