DriveWorks SDK Reference
5.10.90 Release
For Test and Development only

Structure from Motion (SFM) Workflow

Putting It All Together

The following code snippet shows the general structure of a program that uses the SFM module.

while(true)
{
// CODE: Get frame
// CODE: Estimate camera rig pose through odometry
for each camera
{
// CODE: Build pyramid
// CODE: Track features
}
for each camera
{
}
// CODE: Select features to discard
}
DW_API_PUBLIC dwStatus dwReconstructor_estimatePoseAsync(const dwTransformation3f *previousRig2World, const dwTransformation3f *predictedRig2World, const uint32_t listCount, const uint32_t *const d_featureCounts[], const dwFeature2DStatus *const d_statuses[], const dwVector2f *const d_trackedLocations[], const dwVector4f *const d_worldPoints[], dwReconstructorHandle_t obj)
Uses all tracked features from all cameras to estimate the current rig pose.
DW_API_PUBLIC dwStatus dwReconstructor_compactFeatureHistory(const uint32_t cameraIdx, const uint32_t *d_validIndexCount, const uint32_t *d_newToOldMap, dwReconstructorHandle_t obj)
Compacts the internal feature history by keeping only selected features.
DW_API_PUBLIC dwStatus dwReconstructor_updateHistory(int32_t *rig2WorldHistoryIdx, const dwTransformation3f *rig2World, const uint32_t listCount, const uint32_t *const d_featureCounts[], const dwVector2f *const d_trackedLocations[], dwReconstructorHandle_t obj)
Updates the feature and pose history.
DW_API_PUBLIC dwStatus dwReconstructor_initialize(dwReconstructorHandle_t *obj, const dwReconstructorConfig *config, cudaStream_t stream, dwContextHandle_t context)
Creates and initializes a reconstructor.
DW_API_PUBLIC dwStatus dwReconstructor_triangulateFeatures(dwVector4f *d_worldPoints, dwFeature2DStatus *d_statuses, const uint32_t *d_featureCount, const uint32_t cameraIdx, dwReconstructorHandle_t obj)
Triangulates the features of a camera from the internal feature and pose history.
DW_API_PUBLIC dwStatus dwReconstructor_release(dwReconstructorHandle_t obj)
Releases a reconstructor.
DW_API_PUBLIC dwStatus dwReconstructor_compactWorldPoints(dwVector4f *d_worldPoints, const uint32_t *d_validIndexCount, const uint32_t *d_newToOldMap, dwReconstructorHandle_t obj)
Compacts the world point array by keeping only selected features.
DW_API_PUBLIC dwStatus dwReconstructor_predictFeaturePosition(dwVector2f d_predictedLocations[], uint32_t cameraIdx, const dwTransformation3f *previousRigToWorld, const dwTransformation3f *predictedRigToWorld, const uint32_t *d_featureCount, const dwFeature2DStatus d_featureStatuses[], const dwVector2f d_featureLocations[], const dwVector4f d_worldPoints[], dwReconstructorHandle_t obj)
Predicts the positions of features based on the predicted car motion.

For the full implementation refer to Structure from Motion (SFM) Sample