DriveWorks SDK Reference
3.0.4260 Release
For Test and Development only

imageprocessing/geometry/rectifier/docs/usecase1.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020 NVIDIA CORPORATION. All rights reserved.
2 
3 @page rectifier_usecase1 Rectifier Workflow
4 
5 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
6 
7 This tutorial will show you how to convert images captured with a camera model into a different camera model.
8 
9 In this example we'll use as input a camera from our rig configuration file:
10 
11 ```{.cpp}
12 dwInitialize(&contextHandle, DW_VERSION, &sdkParams)
13 dwRig_initializeFromFile(&rigConf, contextHandle, rigConfigFilename);
14 dwRig_findSensorByName(&sensorId, cameraName, rigConf)
15 
16 dwCameraModelHandle_t cameraModelIn = DW_NULL_HANDLE;
17 dwCameraModel_initialize(&cameraModelIn, sensorId, rigConf)
18 ```
19 
20 The following two snippets demonstrate how to initialize different output camera models.<br>
21 `contextHandle` is assumed to be previously initialized `::dwContextHandle_t`.
22 
23 #### Example of camera for rectification (undistortion)
24 
25 ```{.cpp}
26  // Settings
27  dwPinholeCameraConfig cameraConf = {};
28  cameraConf.distortion[0] = 0.f;
29  cameraConf.distortion[1] = 0.f;
30  cameraConf.distortion[2] = 0.f;
31  // CODE: other settings of camera
32  dwCameraModel_initializePinhole(&cameraModelOut, &cameraConf, contextHandle);
33 ```
34 
35 #### Example of camera for model projection (simulation)
36 
37 ```{.cpp}
38  // CODE: create settings of simulated ocam
39  dwCameraModel_initializeOCam(&cameraModelOut, &cameraConf, contextHandle);
40 ```
41 
42 #### Use of the rectifier
43 
44 The rectifier module can be initialized with the camera models that we have just created:
45 
46 ```{.cpp}
47  dwRectifier_initialize(&rectifier, cameraModelIn, cameraModelOut, contextHandle);
48 ```
49 
50 And can be used on images coming from a live sensor or from a recording:
51 
52 ```{.cpp}
53  while(loop) {
54  // CODE: get image from camera, stream it (optional)
55  dwRectifier_setHomography(&homography, rectifier); //optional
56  dwRectifier_warp(&rectifiedImage, inputImage, rectifier);
57  }
58 ```
59 
60 For simplicity, the actual sensor management, including retrieving images from a camera, is omitted in this tutorial.<br>
61 For more information see @ref camera_usecase1.
62 
63 Finally all handles can be released:
64 
65 ```{.cpp}
66 dwCameraModel_release(cameraModelIn);
67 dwCameraModel_release(cameraModelOut);
68 dwRectifier_release(rectifier);
69 dwRelease(contextHandle);
70 ```
71 
72 For the full implementation refer to @ref dwx_video_rectifier_sample.<br>
73 See @ref rig_mainsection for more information on Calibrated Cameras.