DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

src/dw/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 The tutorial shows the general structure of a program that uses the PnP pose estimator to determine the camera pose.
6 
7 #### Initialize the pose estimator
8 
9 We select a conservative number of ransac and non-linear optimizer iterations (10 and 10).
10 `contextHandle` is assumed to be previously initialized `::dwContextHandle_t`.
11 
12 ```{.cpp}
13  dwPnP_initialize(&pnp, 10, 10, contextHandle);
14 
15 ```
16 #### Obtain matches
17 
18 ```{.cpp}
19  dwVector3f worldPoints[BUFFER_SIZE];
20  dwVector2f imagePoints[BUFFER_SIZE];
21  size_t pointCount;
22 
23  // The application must obtain the matches and fill the above three variables
24 
25 ```
26 
27 #### Undistort feature points
28 
29 `cameraModel` is assumed to be previously initialized `::dwCameraModelHandle_t`
30 
31 ```{.cpp}
32  dwVector2f rays[BUFFER_SIZE];
33 
34  for(size_t i = 0; i < pointCount; ++i)
35  {
36  const auto& point = imagePoints[i];
37  auto& ray = rays[i];
38  dwCameraModel_pixel2Ray(&ray.x, &ray.y, &ray.z, point.x, point.y, cameraModel);
39  }
40 
41 ```
42 
43 #### Estimate pose
44 
45 ```{.cpp}
46  dwTransformation3f worldToCamera;
47  dwPnP_solve(&worldToCamera, pointCount, rays, worldPoints, pnp);
48 
49 ```
50 #### Finally, free previously allocated memory.
51 
52 ```{.cpp}
53  dwPnP_release(pnp);
54 ```