DriveWorks SDK Reference
5.20.37 Release
For Test and Development only

Feature Array Interface

Detailed Description

Defines the feature array used by detector and tracker.

Data Structures

struct  dwFeatureArray
 
struct  dwFeatureHistoryArray
 Holds pointers to the data exposed by a feature2d list. More...
 

Enumerations

enum  dwFeature2DStatus {
  DW_FEATURE2D_STATUS_INVALID = 0 ,
  DW_FEATURE2D_STATUS_DETECTED ,
  DW_FEATURE2D_STATUS_TRACKED ,
  DW_FEATURE2D_STATUS_TYPE_COUNT
}
 Defines the possible status of a feature. More...
 

Functions

DW_API_PUBLIC dwStatus dwFeature_mergeNewToOldMap (uint32_t *d_newToOldMapC2A, const uint32_t *d_newToOldMapC2B, const uint32_t *d_newToOldMapB2A, const uint32_t *d_newToOldMapCount, const uint32_t maxFeatureCount, cudaStream_t stream)
 Merge newToOldMap from 2 inputs. More...
 
DW_API_PUBLIC dwStatus dwFeatureArray_convertMemory (dwFeatureArray *outFeatures, const dwFeatureArray *srcFeatures, const dwMemoryType newMemoryType)
 Convert the pointers of given feature array to address space of given memory type. More...
 
DW_API_PUBLIC dwStatus dwFeatureArray_copyAsync (dwFeatureArray *dstFeatures, const dwFeatureArray *srcFeatures, cudaStream_t stream)
 Deep copy all contents from srcFeatures to dstFeatures. More...
 
DW_API_PUBLIC dwStatus dwFeatureArray_create (dwFeatureArray *featureArray, const uint32_t maxFeatureCount, const dwMemoryType memoryType, dwContextHandle_t context)
 Creates and initializes a feature array. More...
 
DW_API_PUBLIC dwStatus dwFeatureArray_createNew (dwFeatureArray *featureArray, const uint32_t maxFeatureCount, const dwMemoryType memoryType, cudaStream_t stream, dwContextHandle_t context)
 Creates and initializes a feature array. More...
 
DW_API_PUBLIC dwStatus dwFeatureArray_destroy (dwFeatureArray featureArray)
 Destroys the featureArray and frees any memory created by dwFeatureArray_createNew(). More...
 
DW_API_PUBLIC dwStatus dwFeatureArray_reset (dwFeatureArray *featureArray, cudaStream_t stream)
 Resets the feature array. More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_convertMemory (dwFeatureHistoryArray *outFeatureHistory, const dwFeatureHistoryArray *srcFeatureHistory, const dwMemoryType newMemoryType)
 Convert the pointers of given feature history array to address space of given memory type. More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_copyAsync (dwFeatureHistoryArray *dstFeatureHistory, const dwFeatureHistoryArray *srcFeatureHistory, cudaStream_t stream)
 Deep copy all contents from srcFeatureHistory to dstFeatureHistory. More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_create (dwFeatureHistoryArray *featureHistoryArray, const uint32_t maxFeatureCount, const uint32_t maxHistoryCapacity, const dwMemoryType memoryType, dwContextHandle_t context)
 Creates and initializes a feature history array. More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_createNew (dwFeatureHistoryArray *featureHistoryArray, const uint32_t maxFeatureCount, const uint32_t maxHistoryCapacity, const dwMemoryType memoryType, cudaStream_t stream, dwContextHandle_t context)
 Creates and initializes a feature history array. More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_destroy (dwFeatureHistoryArray featureHistoryArray)
 Destroys the featureHistoryArray and frees any memory created by dwFeatureHistoryArray_createNew(). More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_get (dwFeatureArray *featureArray, const uint32_t historyIdx, dwFeatureHistoryArray const *featureHistoryArray)
 Get the feature snapshot(arraySize = maxFeatureCount) historyIdx-th frame earlier. More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_getCurrent (dwFeatureArray *featureArray, dwFeatureHistoryArray const *featureHistoryArray)
 Get the latest feature snapshot(arraySize = maxFeatureCount) from history. More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_getPrevious (dwFeatureArray *featureArray, dwFeatureHistoryArray const *featureHistoryArray)
 Get the feature snapshot(arraySize = maxFeatureCount) 1 frame previous to current time. More...
 
DW_API_PUBLIC dwStatus dwFeatureHistoryArray_reset (dwFeatureHistoryArray *featureHistoryArray, cudaStream_t stream)
 Resets the feature history array. More...
 

Data Structure Documentation

◆ dwFeatureArray

struct dwFeatureArray
Data Fields
uint32_t * ages Age of each feature.

1D array of size maxFeatures.

void * devicePointer Base address for the data in device address space.
uint32_t * featureCount Total number of feature points.

Single value.

void * hostPointer Base address for the data in host address space.
uint32_t * ids Id of each feature.

1D array of size maxFeatures.

dwVector2f * locations Location of feature points.

2D array of size maxFeatures.

uint32_t maxFeatures Max number of features.
dwMemoryType memoryType Where feature array is located, GPU, CPU or pinned memory.
uint32_t * newToOldMap New to old index map, 1D array of size maxFeatures.

See more details in dwFeature2DTracker_trackFeatures.

float32_t * scales Scale change for each feature.

1D array of size maxFeatures.

uint32_t sensorId ID of the camera sensor for which the array was generated.

Internal parameter used for NDAS.

dwFeature2DStatus * statuses Status of each feature.

1D array of size maxFeatures.

uint32_t timeIdx Time index, 0 means latest, N means N frames earlier to latest.
uint32_t * validTrackedCount Valid tracked features from last frame.

Single value.

◆ dwFeatureHistoryArray

struct dwFeatureHistoryArray
Data Fields
uint32_t * ages Age of each feature.

1D array of size maxFeatures.

size_t bytes Bytes of raw data.
uint32_t currentTimeIdx Index that points to the latest feature records.
uint8_t * data Pointer to the raw data address.
void * devicePointer Base address for the data in device address space.
uint32_t * featureCount Total number of feature points.

Single value.

void * hostPointer Base address for the data in host address space.
uint32_t * ids Id of each feature.

1D array of size maxFeatures.

dwVector2f * locationHistory Location history of feature points.

2D array of size maxFeatures*maxHistory.

uint32_t maxFeatures Max number of features in one timeIdx.
uint32_t maxHistory Max feature history size.
dwMemoryType memoryType Where feature array is located, GPU, CPU or pinned memory.
uint32_t * newToOldMap New to old index map, 1D array of size maxFeatures.

See more details in dwFeature2DTracker_trackFeatures.

float32_t * scales Scale change for each feature.

1D array of size maxFeatures.

uint32_t sensorId ID of the camera sensor for which the array was generated.

Internal parameter used for NDAS.

dwFeature2DStatus * statuses Status of each feature.

1D array of size maxFeatures.

dwTime_t timestamp Timestamp of the dwFeatureHistoryArray struct, which is the timestamp of the latest image frame being processed.
uint32_t * validTrackedCount Valid tracked features from last frame.

Single value.

Enumeration Type Documentation

◆ dwFeature2DStatus

Defines the possible status of a feature.

Enumerator
DW_FEATURE2D_STATUS_INVALID 

A feature with this entry is garbage.

DW_FEATURE2D_STATUS_DETECTED 

The feature was just detected in the current frame.

DW_FEATURE2D_STATUS_TRACKED 

The feature was successfully tracked in the current frame.

DW_FEATURE2D_STATUS_TYPE_COUNT 

Number of different dwFeature2DStatus enum type, mark as enum end.

Definition at line 62 of file FeatureList.h.

Function Documentation

◆ dwFeature_mergeNewToOldMap()

DW_API_PUBLIC dwStatus dwFeature_mergeNewToOldMap ( uint32_t *  d_newToOldMapC2A,
const uint32_t *  d_newToOldMapC2B,
const uint32_t *  d_newToOldMapB2A,
const uint32_t *  d_newToOldMapCount,
const uint32_t  maxFeatureCount,
cudaStream_t  stream 
)

Merge newToOldMap from 2 inputs.

i.e. There're 3 working stages: A->B->C, newToOldMapC2B gives the mapping of C->B, while newToOldMapB2A gives the mapping of B->A. The final C->A mapping will be computed and output to newToOldMapC2A

Parameters
[out]d_newToOldMapC2AA GPU pointer to the output merged newToOldMap
[in]d_newToOldMapC2BA GPU pointer to newToOldMap from stage C->B
[in]d_newToOldMapB2AA GPU pointer to newToOldMap from stage B->A
[in]d_newToOldMapCountA GPU pointer to valid number of entries in newToOldMapC2B
[in]maxFeatureCountmax number of features for newToOldMapC2A, newToOldMapC2B and newToOldMapB2A
[in]streamWorking cuda stream
Returns
DW_INVALID_ARGUMENT if any of the input argument is NULL.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: Yes
  • De-Init: Yes

◆ dwFeatureArray_convertMemory()

DW_API_PUBLIC dwStatus dwFeatureArray_convertMemory ( dwFeatureArray outFeatures,
const dwFeatureArray srcFeatures,
const dwMemoryType  newMemoryType 
)

Convert the pointers of given feature array to address space of given memory type.

Parameters
[out]outFeaturesoutput converted feature array
[in]srcFeaturesdwFeatureArray to convert memory from
[in]newMemoryTypethe memory type to convert to.
Returns
DW_INVALID_ARGUMENT if srcFeatures.hostPointer == NULL and newMemoryType == CPU
if srcFeatures.devicePointer == NULL and newMemoryType == CUDA
if srcFeatures.memoryType == PINNED or newMemoryType == PINNED

DW_SUCCESS otherwise.

◆ dwFeatureArray_copyAsync()

DW_API_PUBLIC dwStatus dwFeatureArray_copyAsync ( dwFeatureArray dstFeatures,
const dwFeatureArray srcFeatures,
cudaStream_t  stream 
)

Deep copy all contents from srcFeatures to dstFeatures.

Parameters
[out]dstFeaturesdwFeatureArray to copy to
[in]srcFeaturesdwFeatureArray to copy from
[in]streamWorking cuda stream
Returns
DW_INVALID_ARGUMENT if dstFeatures or srcFeatures is NULL.
if dstFeatures.maxFeatures != srcFeatures.maxFeatures.
A specific CUDA error in case of an underlying cuda failure.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: Yes
  • De-Init: Yes

◆ dwFeatureArray_create()

DW_API_PUBLIC dwStatus dwFeatureArray_create ( dwFeatureArray featureArray,
const uint32_t  maxFeatureCount,
const dwMemoryType  memoryType,
dwContextHandle_t  context 
)

Creates and initializes a feature array.

Parameters
[out]featureArraypointer to the dwFeatureArray is returned here.
[in]maxFeatureCountmaximum number of features that the feature array can have.
[in]memoryTypeDW_FEATURE2D_MEMORY_TYPE_CUDA for CUDA array,
DW_FEATURE2D_MEMORY_TYPE_CPU for CPU array,
DW_FEATURE2D_MEMORY_TYPE_PINNED for pinned memory
[in]contexthandle to the context under which it is created.
Returns
DW_INVALID_ARGUMENT if feature arry or context are NULL.
if maxFeatureCount is 0.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: No
  • De-Init: No

◆ dwFeatureArray_createNew()

DW_API_PUBLIC dwStatus dwFeatureArray_createNew ( dwFeatureArray featureArray,
const uint32_t  maxFeatureCount,
const dwMemoryType  memoryType,
cudaStream_t  stream,
dwContextHandle_t  context 
)

Creates and initializes a feature array.

Parameters
[out]featureArraypointer to the dwFeatureArray is returned here.
[in]maxFeatureCountmaximum number of features that the feature array can have.
[in]memoryTypeDW_FEATURE2D_MEMORY_TYPE_CUDA for CUDA array,
DW_FEATURE2D_MEMORY_TYPE_CPU for CPU array,
DW_FEATURE2D_MEMORY_TYPE_PINNED for pinned memory
[in]streamWorking CUDA stream
[in]contexthandle to the context under which it is created.
Returns
DW_INVALID_ARGUMENT if feature arry or context are NULL.
if maxFeatureCount is 0.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: No
  • De-Init: No

◆ dwFeatureArray_destroy()

DW_API_PUBLIC dwStatus dwFeatureArray_destroy ( dwFeatureArray  featureArray)

Destroys the featureArray and frees any memory created by dwFeatureArray_createNew().

Parameters
[in]featureArrayfeature array to be destroyed.
Returns
DW_INVALID_ARGUMENT if featureArray contains invalid pointers.
DW_SUCCESS otherwise.
Note
dwFeatureArray got by dwFeatureHistoryArray_get*() API doesn't need to be destroyed by this API, all resource will be freed when calling dwFeatureHistoryArray_destroy().
API Group
  • Init: Yes
  • Runtime: No
  • De-Init: Yes

◆ dwFeatureArray_reset()

DW_API_PUBLIC dwStatus dwFeatureArray_reset ( dwFeatureArray featureArray,
cudaStream_t  stream 
)

Resets the feature array.

Sets the feature count back to zero.

Parameters
[in]featureArrayfeature array to be reset.
[in]streamCUDA stream used to reset the feature array
Returns
DW_INVALID_ARGUMENT if featureArray.featureCount is NULL.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: Yes
  • De-Init: Yes

◆ dwFeatureHistoryArray_convertMemory()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_convertMemory ( dwFeatureHistoryArray outFeatureHistory,
const dwFeatureHistoryArray srcFeatureHistory,
const dwMemoryType  newMemoryType 
)

Convert the pointers of given feature history array to address space of given memory type.

Parameters
[out]outFeatureHistoryoutput converted feature history array
[in]srcFeatureHistorydwFeatureHistoryArray to convert memory from
[in]newMemoryTypethe memory type to convert to.
Returns
DW_INVALID_ARGUMENT if srcFeatureHistory.hostPointer == NULL and newMemoryType == CPU
if srcFeatureHistory.devicePointer == NULL and newMemoryType == CUDA
if srcFeatureHistory.memoryType == PINNED or newMemoryType == PINNED

DW_SUCCESS otherwise.

◆ dwFeatureHistoryArray_copyAsync()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_copyAsync ( dwFeatureHistoryArray dstFeatureHistory,
const dwFeatureHistoryArray srcFeatureHistory,
cudaStream_t  stream 
)

Deep copy all contents from srcFeatureHistory to dstFeatureHistory.

Parameters
[out]dstFeatureHistorydwFeatureHistoryArray to copy to
[in]srcFeatureHistorydwFeatureHistoryArray to copy from
[in]streamWorking cuda stream
Returns
DW_INVALID_ARGUMENT if dstFeatureHistory or srcFeatureHistory is NULL.
if dstFeatureHistory.bytes != srcFeaturesHistory.bytes.
A specific CUDA error in case of an underlying cuda failure.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: Yes
  • De-Init: Yes

◆ dwFeatureHistoryArray_create()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_create ( dwFeatureHistoryArray featureHistoryArray,
const uint32_t  maxFeatureCount,
const uint32_t  maxHistoryCapacity,
const dwMemoryType  memoryType,
dwContextHandle_t  context 
)

Creates and initializes a feature history array.

Parameters
[out]featureHistoryArraypointer to the dwFeatureHistoryArray is returned here.
[in]maxFeatureCountmaximum number of features that each time slice can have.
[in]maxHistoryCapacitymaximum length of history in feature history array. There'll be maxFeatureCount*maxHistoryCapacity features totally.
[in]memoryTypeDW_FEATURE2D_MEMORY_TYPE_CUDA for CUDA array,
DW_FEATURE2D_MEMORY_TYPE_CPU for CPU array,
DW_FEATURE2D_MEMORY_TYPE_PINNED for pinned memory
[in]contexthandle to the context under which it is created.
Returns
DW_INVALID_ARGUMENT if feature arry or context are NULL.
if maxFeatureCount or maxHistoryCapacity is 0.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: No
  • De-Init: No

◆ dwFeatureHistoryArray_createNew()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_createNew ( dwFeatureHistoryArray featureHistoryArray,
const uint32_t  maxFeatureCount,
const uint32_t  maxHistoryCapacity,
const dwMemoryType  memoryType,
cudaStream_t  stream,
dwContextHandle_t  context 
)

Creates and initializes a feature history array.

Parameters
[out]featureHistoryArraypointer to the dwFeatureHistoryArray is returned here.
[in]maxFeatureCountmaximum number of features that each time slice can have.
[in]maxHistoryCapacitymaximum length of history in feature history array. There'll be maxFeatureCount*maxHistoryCapacity features totally.
[in]memoryTypeDW_FEATURE2D_MEMORY_TYPE_CUDA for CUDA array,
DW_FEATURE2D_MEMORY_TYPE_CPU for CPU array,
DW_FEATURE2D_MEMORY_TYPE_PINNED for pinned memory
[in]streamWorking CUDA stream
[in]contexthandle to the context under which it is created.
Returns
DW_INVALID_ARGUMENT if feature arry or context are NULL.
if maxFeatureCount or maxHistoryCapacity is 0.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: No
  • De-Init: No

◆ dwFeatureHistoryArray_destroy()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_destroy ( dwFeatureHistoryArray  featureHistoryArray)

Destroys the featureHistoryArray and frees any memory created by dwFeatureHistoryArray_createNew().

Parameters
[in]featureHistoryArrayfeature history array to be destroyed.
Returns
DW_INVALID_ARGUMENT if featureHistoryArray contains invalid pointers.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: No
  • De-Init: Yes

◆ dwFeatureHistoryArray_get()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_get ( dwFeatureArray featureArray,
const uint32_t  historyIdx,
dwFeatureHistoryArray const *  featureHistoryArray 
)

Get the feature snapshot(arraySize = maxFeatureCount) historyIdx-th frame earlier.

Assuming dwFeatureHistoryArray has N valid features in current Time(t), this API returns a dwFeatureArray that contains the snapshot of those N features in Time(t-historyIdx)

Parameters
[out]featureArraySnapshot of the timeIdx that is historyIdx frame previous to current in feature history.
[in]historyIdxTime index that need to be backtraced.
[in]featureHistoryArrayComplete feature history.
Returns
DW_INVALID_ARGUMENT if featureArray or featureHistoryArray is NULL
DW_SUCCESS otherwise
Note
featureArray got by this API DOES NOT need to be freed by dwFeatureArray_destroy().
API Group
  • Init: Yes
  • Runtime: Yes
  • De-Init: Yes

◆ dwFeatureHistoryArray_getCurrent()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_getCurrent ( dwFeatureArray featureArray,
dwFeatureHistoryArray const *  featureHistoryArray 
)

Get the latest feature snapshot(arraySize = maxFeatureCount) from history.

Parameters
[out]featureArraySnapshot of latest time in feature history.
[in]featureHistoryArrayComplete feature history.
Returns
DW_INVALID_ARGUMENT if featureArray or featureHistoryArray is NULL.
DW_SUCCESS otherwise.
Note
featureArray got by this API DOES NOT need to be freed by dwFeatureArray_destroy().
API Group
  • Init: Yes
  • Runtime: Yes
  • De-Init: Yes

◆ dwFeatureHistoryArray_getPrevious()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_getPrevious ( dwFeatureArray featureArray,
dwFeatureHistoryArray const *  featureHistoryArray 
)

Get the feature snapshot(arraySize = maxFeatureCount) 1 frame previous to current time.

Assuming dwFeatureHistoryArray has N valid features in current Time(t), this API returns a dwFeatureArray that contains the snapshot of those N features in Time(t-1).

Parameters
[out]featureArraySnapshot of the timeIdx that is 1 frame previous to current in feature history.
[in]featureHistoryArrayComplete feature history.
Returns
DW_INVALID_ARGUMENT if featureArray or featureHistoryArray is NULL.
DW_SUCCESS otherwise.
Note
featureArray got by this API DOES NOT need to be freed by dwFeatureArray_destroy()
API Group
  • Init: Yes
  • Runtime: Yes
  • De-Init: Yes

◆ dwFeatureHistoryArray_reset()

DW_API_PUBLIC dwStatus dwFeatureHistoryArray_reset ( dwFeatureHistoryArray featureHistoryArray,
cudaStream_t  stream 
)

Resets the feature history array.

Sets the feature count back to zero.

Parameters
[in]featureHistoryArrayfeature history array to be reset.
[in]streamCUDA stream used to reset the feature history array
Returns
DW_INVALID_ARGUMENT if featureHistoryArray.featureCount is NULL.
DW_SUCCESS otherwise.
API Group
  • Init: Yes
  • Runtime: Yes
  • De-Init: Yes