DriveWorks SDK Reference
3.5.78 Release
For Test and Development only

advancedfunctions/lightsourceperception/docs/lightsourceperception_usecase1.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
2 
3 @page lightsourceperception_usecase1 LigthSourceDetector Workflow
4 
5 ## Initialization
6 
7 The LightSourceDetector module creates handle of type `dwLightSourceDetectorHandle_t`. This handle is owned by the application and must be released by the application when not needed anymore.
8 
9 An instance of type `dwLightSourceDetectorParams` encodes parameters (currently only perception ROI) and encapsulates a handle to LightSourceNet (of type `dwLightSourceNetHandle_t`) that configures the LightSourceDetector module.
10 
11 To initialize a pointer to a `dwLightSourceDetectorHandle_t` instance with an initialized LightSourceNet handle and default parameter values:
12 
13 ```{.cpp}
14 dwStatus dwLightSourceDetector_initialize(dwLightSourceDetectorHandle_t* obj,
15  dwLightSourceNetHandle_t ligthSourceNet,
16  dwContextHandle_t ctx);
17 ```
18 
19 An example code snippet to initialize required modules with default values:
20 
21 ```{.cpp}
22 dwLightSourceNetHandle_t m_lightSourceNet = DW_NULL_HANDLE;
23 dwLightSourceNetParams m_lightSourceNetParams{};
24 dwLightSourceDetectorHandle_t m_lightSourceDetector = DW_NULL_HANDLE;
25 
26 // Initialize LightSourceNet
27 CHECK_DW_ERROR(dwLightSourceNet_initDefaultParams(&m_lightSourceNetParams));
28 CHECK_DW_ERROR(dwLightSourceNet_initialize(&m_lightSourceNet, &m_lightSourceNetParams, m_sdk));
29 
30 // dwLightSourceDetector_initialize
31 CHECK_DW_ERROR(dwLightSourceDetector_initialize(&m_lightSourceDetector, m_lightSourceNet, m_sdk));
32 ```
33 
34 where `m_sdk` is an initialized instance of `dwContextHandle_t`.
35 
36 ## Processing
37 
38 With initialized handle to the LightSourceDetector module, the following functions can be used to perform inference on an image and retrieve the processed output, which indicate binary ON/OFF high beam signal:
39 
40 ```{.cpp}
41 typedef struct
42 {
43  /// High beam ON/OFF binary flag.
44  bool flag;
45 
46 } dwLightSourceDetectorAutoBeamStatus;
47 
48 DW_API_PUBLIC
49 dwStatus dwLightSourceDetector_bindInput(const dwImageCUDA* imageRGB,
50  const dwImageCUDA* imageBayer,
51  dwLightSourceDetectorHandle_t obj);
52 
53 DW_API_PUBLIC
54 dwStatus dwLightSourceDetector_bindOutputAutoBeamStatus(dwLightSourceDetectorAutoBeamStatus* output,
55  dwLightSourceDetectorHandle_t obj);
56 
57 DW_API_PUBLIC
58 dwStatus dwLightSourceDetector_bindOutputDetectorMask(dwLightSourceDetectorMask* output,
59  dwLightSourceDetectorHandle_t obj);
60 
61 typedef enum {
62  /// Input image is preprocessed on GPU side with certain predefined transformations
63  /// in order to have the right properties required by DNN inference.
64  DW_LSP_DETECTOR_STAGE_GPU_PREPROCESS = 0,
65 
66  /// DNN inference is run on prepared image.
67  DW_LSP_DETECTOR_STAGE_GPU_INFERENCE = 1,
68 
69  /// DNN inference is run on prepared image.
70  DW_LSP_DETECTOR_STAGE_GPU_POSTPROCESS = 2,
71 
72  /// After inference CPU runs post processing.
73  DW_LSP_DETECTOR_STAGE_CPU_POSTPROCESS = 3,
74 
75 } dwLightSourceDetectorStage;
76 
77 DW_API_PUBLIC
78 dwStatus dwLightSourceDetector_process(dwLightSourceDetectorStage stage,
79  dwLightSourceDetectorHandle_t obj);
80 
81 ```
82 
83 ## Release
84 
85 The following functions can be used to reset or release the initialized module handles whenever necessary:
86 
87 ```{.cpp}
88 dwStatus dwLightSourceDetector_release(dwLightSourceDetectorHandle_t obj);
89 ```
90 
91 For usage of a sample application, please refer to @ref dwx_lightsourceperception_sample.
92 
93 ## Additional Information
94 
95 See @ref lightsourcenet_mainsection for information on DNN used in this perception module (LightSourceNet).