1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3 @page waitcondition_usecase4 Wait Conditions Detector with Temporal Analysis Workflow
5 @note SW Release Applicability: This tutorial is applicable to modules in **NVIDIA DRIVE Software** releases.
9 TemporalAnalysis optionally can be used with WaitConditionsDetector to track and stabilize the detected intersection over the frames. Please refer to @ref waitcondition_usecase1 and @ref waitnet_usecase1 for more details about how to initialize and use the WaitNet DNN and WaitConditionsDetector modules first.
11 TemporalAnalysis module creates handle of type `dwTemporalAnalysisHandle_t`. This handle is owned by the application and must be released by the application when not needed anymore.
13 An instance of type `dwWaitConditionsDetectorTemporalAnalysisParams` encodes parameters that configures the TemporalAnalysis module before initialization. There is no function to initialize this data structure with default values. So all the values must be initialized manually. Here is an example:
16 dwWaitConditionsDetectorTemporalAnalysisParams taParams = {};
19 taParams.gpuPostProc = true;
20 taParams.scaleToCameraImage = 2.0;
21 taParams.detectionNegativeCount = 15; // number of frames of negative detections before stop seeing intersection (15 - 1/2 sec)
22 taParams.detectionPositiveCount = 15; // number of frames of positive detections before start seeing intersection (15 - 1/2 sec)
23 taParams.directLineDistance = 5.0; // direct line distance (blend between euclidean distance and direct distance when within this range)
24 taParams.egoMotionOnlyDistance = 12.0; // rig to intersection distance after which only egomotion is considered to track intersection's position
25 taParams.parzenWindowSize = 20;
26 taParams.kdeSigma = 1.0;
27 taParams.peakDetectionThreshold = 0.3; // PDF peak detection threshold
28 taParams.validEvidenceThreshold = 0.3; // 0-1 confidence level to accept bbox evidence into temporal filter
30 // range parameters: x - direct perpendicular distance, y - lateral distance (called "angle" in the code)
31 taParams.xRangeMin = 0.0;
32 taParams.xRangeMax = 200.0;
33 taParams.yRangeMin = -100.0;
34 taParams.yRangeMax = 100.0;
36 // roll/pitch active correction, filter coefficients
37 taParams.rollFilterK0 = 0.07;
38 taParams.rollFilterK1 = 0.3;
39 taParams.rollFilterK2 = 0.4;
40 taParams.pitchFilterK0 = 0.07;
41 taParams.pitchFilterK1 = 0.3;
42 taParams.pitchFilterK2 = 0.4;
45 `taParams` can now be used to initialize the TemporalAnalysis module:
48 dwTemporalAnalysisHandle_t m_temporalAnalysisHandle = DW_NULL_HANDLE;
50 CHECK_DW_ERROR(dwTemporalAnalysis_initializeSimple(&m_temporalAnalysisHandle,
58 The function `dwTemporalAnalysis_initializeSimple()` instantiates the TemporalAnalysis module and assigns the pointer to `m_temporalAnalysisHandle` handle. `m_ctx` is an initialized instance of `::dwContextHandle_t`.
60 `cam2Rig` and `cam` specify the extrinsic and intrinsic of the camera. `cam2Rig` is a pointer to "camera to rig" transformation matrix and `cam` is a handle to calibrated camera. `m_egoMotion` is a handle to an instance of EgoMotion. These parameters are necessary to map the pixels that are in image-space to real world coordinates and track intersection's position and distance.
62 ## Temporal Analysis Process
64 After we get the detected intersection from WaitConditionsDetector module (@ref waitcondition_usecase1), we can process it using TemporalAnalysis:
67 CHECK_DW_ERROR(dwTemporalAnalysis_setTargetTimestamp(camFrameTime, m_temporalAnalysisHandle));
68 CHECK_DW_ERROR(dwTemporalAnalysis_addIntersectionEvidence(
70 requireTransformToGround,
71 m_temporalAnalysisHandle));
72 CHECK_DW_ERROR(dwTemporalAnalysis_runTemporalAnalysis(m_temporalAnalysisHandle));
73 CHECK_DW_ERROR(dwTemporalAnalysis_getSmoothedIntersection(
75 m_temporalAnalysisHandle));
78 `intersection` which is an instance of `dwIntersectionDetection`, contains the intersection detected by WaitConditionsDetector module and returned by `dwWaitConditionsDetector_getDetectedIntersection()` function (@ref waitcondition_usecase1).
80 `dwTemporalAnalysis_setTargetTimestamp()` sets the current time-stamp and associates it with the detected intersection. `camFrameTime` is the time-stamp of current camera frame. `dwTemporalAnalysis_addIntersectionEvidence()` adds detected intersection to list of evidences to be processed. `requireTransformToGround` is a boolean specifying whether a point in image space should be transformed into a 3-dimensional ground point or not (default is true). `dwTemporalAnalysis_runTemporalAnalysis()` uses the current evidence to perform the analysis. `dwTemporalAnalysis_getSmoothedIntersection()` can be used to get output of TemporalAnalysis which updates the `intersection` object with the tracked and temporally smoothed intersection after the call.
82 The following function can be used to set the CUDA stream:
85 dwStatus dwTemporalAnalysis_setCUDAStream(cudaStream_t stream,
86 dwTemporalAnalysisHandle_t temporalAnalysisHandle);
89 The following function can be used to change extrinsic calibration during runtime if necessary:
92 dwStatus dwTemporalAnalysis_setCameraToRig(
93 const dwTransformation3f* cam2Rig, dwTemporalAnalysisHandle_t temporalAnalysisHandle);
98 The following function can be used to release the module:
101 dwStatus dwTemporalAnalysis_release(
102 dwTemporalAnalysisHandle_t temporalAnalysisHandle);