DriveWorks SDK Reference
3.0.4260 Release
For Test and Development only

imageprocessing/geometry/pose/docs/usecase1.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
2 
3 @page imageprocessing_geometry_pose_usecase1 Pose estimation
4 
5 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
6 
7 The tutorial shows the general structure of a program that uses the PnP pose estimator to determine the camera pose.
8 
9 #### Initialize the pose estimator
10 
11 We select a conservative number of ransac and non-linear optimizer iterations (10 and 10).
12 `contextHandle` is assumed to be previously initialized `::dwContextHandle_t`.
13 
14 ```{.cpp}
15  dwPnP_initialize(&pnp, 10, 10, contextHandle);
16 
17 ```
18 #### Obtain matches
19 
20 ```{.cpp}
21  dwVector3f worldPoints[BUFFER_SIZE];
22  dwVector2f imagePoints[BUFFER_SIZE];
23  size_t pointCount;
24 
25  // The application must obtain the matches and fill the above three variables
26 
27 ```
28 
29 #### Undistort feature points
30 
31 `cameraModel` is assumed to be previously initialized `::dwCameraModelHandle_t`
32 
33 ```{.cpp}
34  dwVector2f rays[BUFFER_SIZE];
35 
36  for(size_t i = 0; i < pointCount; ++i)
37  {
38  const auto& point = imagePoints[i];
39  auto& ray = rays[i];
40  dwCameraModel_pixel2Ray(&ray.x, &ray.y, &ray.z, point.x, point.y, cameraModel);
41  }
42 
43 ```
44 
45 #### Estimate pose
46 
47 ```{.cpp}
48  dwTransformation3f worldToCamera;
49  dwPnP_solve(&worldToCamera, pointCount, rays, worldPoints, pnp);
50 
51 ```
52 #### Finally, free previously allocated memory.
53 
54 ```{.cpp}
55  dwPnP_release(pnp);
56 ```