1 # Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
3 @page clearsightnet_usecase1 ClearSightNet Workflow
7 The ClearSightNet and ClearSightNetDetector modules create handles of types `dwClearSightNetHandle_t` and `dwBlindnessDetectorHandle_t` respectively. Both of these handles are owned by the application and must be released by the application when not needed anymore.
9 An instance of type `dwClearSightNetParams` encodes parameters that configure the ClearSightNet module. To initialize default ClearSightNet parameters:
12 dwStatus dwClearSightNet_initDefaultParams(dwClearSightNetParams* clearSightNetParams);
15 To initialize a pointer to a `dwClearSightNetHandle_t` instance with default parameter values:
18 dwStatus dwClearSightNet_initialize(dwClearSightNetHandle_t* clearSightNetHandle,
19 const dwClearSightNetParams* clearSightNetParams,
20 dwContextHandle_t ctx);
23 An instance of type `dwBlindnessDetectorParams` encapsulates several configuration parameters and encapsulates a handle to ClearSightNet (of type `dwClearSightNetHandle_t`) that configure the BlindnessDetector module.
25 To initialize in instance of `dwBlindnessDetectorParams` with default values:
28 dwStatus dwBlindnessDetector_initDefaultParams(dwBlindnessDetectorParams *clearSightNetDetectorParams);
31 This initializes the members `dwBlindnessDetectorParams.temporalFilterWindow`, `dwBlindnessDetectorParams.numRegionsX` and `dwBlindnessDetectorParams.numRegionsY` to 5, 1 and 1 respectively.
33 To initialize a pointer to a `dwBlindnessDetectorHandle_t` instance with an initialized ClearSightNet handle and default parameter values:
36 dwStatus dwBlindnessDetector_initialize(dwClearSightNetDetectorHandle_t* clearSightNetDetectorHandle,
37 dwBlindnessDetectorParams *clearSightNetDetectorParams,
38 dwContextHandle_t ctx);
41 An example code snippet to initialize required modules with default values to perfrom inference on GPU:
44 // Initialize ClearSightNet
45 dwClearSightNetParams m_clearSightNetParams;
46 dwBlindnessDetectorParams m_detectorParams;
47 CHECK_DW_ERROR(dwClearSightNet_initDefaultParams(&m_clearSightNetParams));
48 CHECK_DW_ERROR(dwClearSightNet_initialize(&m_detectorParams.clearSightNetHandle,
49 &m_clearSightNetParams,
52 dwBlindnessDetectorHandle_t m_clearSightNetDetector;
53 CHECK_DW_ERROR(dwBlindnessDetector_initDefaultParams(&clearSightNetDetectorParams));
54 CHECK_DW_ERROR(dwBlindnessDetector_initialize(&m_clearSightNetDetector,
59 where `m_sdk` is an initialized instance of `dwContextHandle_t`.
61 Another code snippet to initialize required modules with parameters that enable 3 sub-regions in each direction:
64 // Initialize ClearSightNet
65 dwClearSightNetParams m_clearSightNetParams;
66 dwBlindnessDetectorParams m_detectorParams;
67 CHECK_DW_ERROR(dwClearSightNet_initDefaultParams(&m_clearSightNetParams));
68 CHECK_DW_ERROR(dwClearSightNet_initialize(&m_detectorParams.clearSightNetHandle,
69 &m_clearSightNetParams,
72 dwBlindnessDetectorHandle_t m_clearSightNetDetector;
73 CHECK_DW_ERROR(dwBlindnessDetector_initDefaultParams(&clearSightNetDetectorParams));
74 m_detectorParams.numRegionsX = 3U;
75 m_detectorParams.numRegionsY = 3U;
76 m_detectorParams.regionDividersX[0] = 0.2f; m_detectorParams.regionDividersX[1] = 0.8f;
77 m_detectorParams.regionDividersY[0] = 0.2f; m_detectorParams.regionDividersY[1] = 0.8f;
78 CHECK_DW_ERROR(dwBlindnessDetector_initialize(&m_clearSightNetDetector,
83 Note that values for parameters `dwBlindnessDetectorParams.regionDividersX` and `dwBlindnessDetectorParams.regionDividersY` are specified in image fractions. This will create sub-region dividers at 20% and 80% of image width and height.
85 ## Query Network Specs
87 With initialized handle to the ClearSightNet module, the following functions can be used to query size of expected input blob, size of output blob and network metadata respectively:
90 dwStatus dwClearSightNet_getInputBlobSize(dwBlobSize* inputBlobsize, dwClearSightNetHandle_t clearSightNetHandle);
94 dwStatus dwClearSightNet_getOutputBlobSize(dwBlobSize* outputBlobsize, dwClearSightNetHandle_t clearSightNetHandle);
98 dwStatus dwClearSightNet_getDNNMetaData(dwDNNMetaData* metaData, dwClearSightNetHandle_t clearSightNetHandle);
103 With initialized handle to the ClearSightNetDetector module, the following functions can be used to perform inference on an image and retrieve the processed output:
106 dwStatus dwBlindnessDetector_detect(const dwImageCUDA* image,
107 dwBlindnessDetectorHandle_t clearSightNetDetectorHandle);
111 dwStatus dwBlindnessDetector_getOutput(dwBlindnessDetectionOutput *outputs,
112 dwBlindnessDetectorHandle_t clearSightNetDetectorHandle);
115 The `dwBlindnessDetector_detect()` function performs inference asynchronously. This means that an inference call can be queued using `dwBlindnessDetector_detect()` and then other computation can be performed and `dwBlindnessDetector_getOutput()`, whenever called, will automatically wait for the inference to finish before returning the output. To this end, the following functions can be used to set and get CUDA the stream used by the module:
118 dwStatus dwBlindnessDetector_setCUDAStream(const cudaStream_t stream, dwBlindnessDetectorHandle_t clearSightNetDetectorHandle);
122 dwStatus dwBlindnessDetector_getCUDAStream(cudaStream_t *stream, dwBlindnessDetectorHandle_t clearSightNetDetectorHandle);
127 The following functions can be used to reset or release the initialized module handles whenever necessary:
130 dwStatus dwClearSightNet_reset(dwClearSightNetHandle_t clearSightNetHandle);
134 dwStatus dwClearSightNet_release(dwClearSightNetHandle_t clearSightNetHandle);
138 dwStatus dwBlindnessDetector_reset(dwBlindnessDetectorHandle_t clearSightNetDetectorHandle);
142 dwStatus dwBlindnessDetector_release(dwBlindnessDetectorHandle_t clearSightNetDetectorHandle);
145 For usage of a sample application, please refer to @ref dwx_clearsightnet_sample.