|
6 | 6 | #pragma once |
7 | 7 |
|
8 | 8 | #include "Types.hpp" |
| 9 | +#include "Frame.hpp" |
9 | 10 |
|
10 | 11 | namespace ob { |
11 | 12 | class Device; |
12 | 13 |
|
13 | 14 | class OB_EXTENSION_API CoordinateTransformHelper { |
14 | | -public: |
15 | | - /** |
16 | | - * @brief Transform a 3d point of a source coordinate system into a 3d point of the target coordinate system. |
17 | | - * |
18 | | - * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
19 | | - * @param sourcePoint3f Source 3d point value |
20 | | - * @param sourceSensorType Source sensor type |
21 | | - * @param targetSensorType Target sensor type |
22 | | - * @param targetPoint3f Target 3d point value |
23 | | - * |
24 | | - * @return bool Transform result |
25 | | - */ |
26 | | - static bool calibration3dTo3d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType, |
27 | | - const OBSensorType targetSensorType, OBPoint3f *targetPoint3f); |
| 15 | + public: |
| 16 | + /** |
| 17 | + * @brief Transform a 3d point of a source coordinate system into a 3d point of the target |
| 18 | + * coordinate system. |
| 19 | + * |
| 20 | + * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
| 21 | + * @param sourcePoint3f Source 3d point value |
| 22 | + * @param sourceSensorType Source sensor type |
| 23 | + * @param targetSensorType Target sensor type |
| 24 | + * @param targetPoint3f Target 3d point value |
| 25 | + * |
| 26 | + * @return bool Transform result |
| 27 | + */ |
| 28 | + static bool calibration3dTo3d(const OBCalibrationParam calibrationParam, |
| 29 | + const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType, |
| 30 | + const OBSensorType targetSensorType, OBPoint3f *targetPoint3f); |
28 | 31 |
|
29 | | - /** |
30 | | - * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 3d point of the target coordinate system. |
31 | | - * |
32 | | - * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
33 | | - * @param sourcePoint2f Source 2d point value |
34 | | - * @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters |
35 | | - * @param sourceSensorType Source sensor type |
36 | | - * @param targetSensorType Target sensor type |
37 | | - * @param targetPoint3f Target 3d point value |
38 | | - * |
39 | | - * @return bool Transform result |
40 | | - */ |
41 | | - static bool calibration2dTo3d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue, |
42 | | - const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint3f *targetPoint3f); |
| 32 | + /** |
| 33 | + * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into |
| 34 | + * a 3d point of the target coordinate system. |
| 35 | + * |
| 36 | + * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
| 37 | + * @param sourcePoint2f Source 2d point value |
| 38 | + * @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters |
| 39 | + * @param sourceSensorType Source sensor type |
| 40 | + * @param targetSensorType Target sensor type |
| 41 | + * @param targetPoint3f Target 3d point value |
| 42 | + * |
| 43 | + * @return bool Transform result |
| 44 | + */ |
| 45 | + static bool calibration2dTo3d(const OBCalibrationParam calibrationParam, |
| 46 | + const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue, |
| 47 | + const OBSensorType sourceSensorType, |
| 48 | + const OBSensorType targetSensorType, OBPoint3f *targetPoint3f); |
43 | 49 |
|
44 | | - /** |
45 | | - * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 3d point of the target coordinate system. |
46 | | - * @brief This function uses undistortion, which may result in longer processing time. |
47 | | - * |
48 | | - * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
49 | | - * @param sourcePoint2f Source 2d point value |
50 | | - * @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters |
51 | | - * @param sourceSensorType Source sensor type |
52 | | - * @param targetSensorType Target sensor type |
53 | | - * @param targetPoint3f Target 3d point value |
54 | | - * |
55 | | - * @return bool Transform result |
56 | | - */ |
57 | | - static bool calibration2dTo3dUndistortion(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue, |
58 | | - const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint3f *targetPoint3f); |
| 50 | + /** |
| 51 | + * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into |
| 52 | + * a 3d point of the target coordinate system. |
| 53 | + * @brief This function uses undistortion, which may result in longer processing time. |
| 54 | + * |
| 55 | + * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
| 56 | + * @param sourcePoint2f Source 2d point value |
| 57 | + * @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters |
| 58 | + * @param sourceSensorType Source sensor type |
| 59 | + * @param targetSensorType Target sensor type |
| 60 | + * @param targetPoint3f Target 3d point value |
| 61 | + * |
| 62 | + * @return bool Transform result |
| 63 | + */ |
| 64 | + static bool calibration2dTo3dUndistortion(const OBCalibrationParam calibrationParam, |
| 65 | + const OBPoint2f sourcePoint2f, |
| 66 | + const float sourceDepthPixelValue, |
| 67 | + const OBSensorType sourceSensorType, |
| 68 | + const OBSensorType targetSensorType, |
| 69 | + OBPoint3f *targetPoint3f); |
59 | 70 |
|
60 | | - /** |
61 | | - * @brief Transform a 3d point of a source coordinate system into a 2d pixel coordinate of the target camera. |
62 | | - * |
63 | | - * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
64 | | - * @param sourcePoint3f Source 3d point value |
65 | | - * @param sourceSensorType Source sensor type |
66 | | - * @param targetSensorType Target sensor type |
67 | | - * @param targetPoint2f Target 2d point value |
68 | | - * |
69 | | - * @return bool Transform result |
70 | | - */ |
71 | | - static bool calibration3dTo2d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType, |
72 | | - const OBSensorType targetSensorType, OBPoint2f *targetPoint2f); |
| 71 | + /** |
| 72 | + * @brief Transform a 3d point of a source coordinate system into a 2d pixel coordinate of the |
| 73 | + * target camera. |
| 74 | + * |
| 75 | + * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
| 76 | + * @param sourcePoint3f Source 3d point value |
| 77 | + * @param sourceSensorType Source sensor type |
| 78 | + * @param targetSensorType Target sensor type |
| 79 | + * @param targetPoint2f Target 2d point value |
| 80 | + * |
| 81 | + * @return bool Transform result |
| 82 | + */ |
| 83 | + static bool calibration3dTo2d(const OBCalibrationParam calibrationParam, |
| 84 | + const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType, |
| 85 | + const OBSensorType targetSensorType, OBPoint2f *targetPoint2f); |
73 | 86 |
|
74 | | - /** |
75 | | - * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 2d pixel coordinate of the target camera |
76 | | - * |
77 | | - * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
78 | | - * @param sourcePoint2f Source 2d point value |
79 | | - * @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters |
80 | | - * @param sourceSensorType Source sensor type |
81 | | - * @param targetSensorType Target sensor type |
82 | | - * @param targetPoint2f Target 2d point value |
83 | | - * |
84 | | - * @return bool Transform result |
85 | | - */ |
86 | | - static bool calibration2dTo2d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue, |
87 | | - const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint2f *targetPoint2f); |
| 87 | + /** |
| 88 | + * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into |
| 89 | + * a 2d pixel coordinate of the target camera |
| 90 | + * |
| 91 | + * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
| 92 | + * @param sourcePoint2f Source 2d point value |
| 93 | + * @param sourceDepthPixelValue The depth of sourcePoint2f in millimeters |
| 94 | + * @param sourceSensorType Source sensor type |
| 95 | + * @param targetSensorType Target sensor type |
| 96 | + * @param targetPoint2f Target 2d point value |
| 97 | + * |
| 98 | + * @return bool Transform result |
| 99 | + */ |
| 100 | + static bool calibration2dTo2d(const OBCalibrationParam calibrationParam, |
| 101 | + const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue, |
| 102 | + const OBSensorType sourceSensorType, |
| 103 | + const OBSensorType targetSensorType, OBPoint2f *targetPoint2f); |
88 | 104 |
|
89 | | - /** |
90 | | - * @brief Transforms the depth frame into the geometry of the color camera. |
91 | | - * |
92 | | - * @param device Device handle |
93 | | - * @param depthFrame Input depth frame |
94 | | - * @param targetColorCameraWidth Target color camera width |
95 | | - * @param targetColorCameraHeight Target color camera height |
96 | | - * |
97 | | - * @return std::shared_ptr<ob::Frame> Transformed depth frame |
98 | | - */ |
99 | | - static std::shared_ptr<ob::Frame> transformationDepthFrameToColorCamera(std::shared_ptr<ob::Device> device, std::shared_ptr<ob::Frame> depthFrame, |
100 | | - uint32_t targetColorCameraWidth, uint32_t targetColorCameraHeight); |
| 105 | + /** |
| 106 | + * @brief Transforms the depth frame into the geometry of the color camera. |
| 107 | + * |
| 108 | + * @param device Device handle |
| 109 | + * @param depthFrame Input depth frame |
| 110 | + * @param targetColorCameraWidth Target color camera width |
| 111 | + * @param targetColorCameraHeight Target color camera height |
| 112 | + * |
| 113 | + * @return std::shared_ptr<ob::Frame> Transformed depth frame |
| 114 | + */ |
| 115 | + static std::shared_ptr<ob::Frame> transformationDepthFrameToColorCamera( |
| 116 | + std::shared_ptr<ob::Device> device, std::shared_ptr<ob::Frame> depthFrame, |
| 117 | + uint32_t targetColorCameraWidth, uint32_t targetColorCameraHeight); |
101 | 118 |
|
102 | | - /** |
103 | | - * @brief Init transformation tables |
104 | | - * |
105 | | - * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
106 | | - * @param sensorType sensor type |
107 | | - * @param data input data,needs to be allocated externally.During initialization, the external allocation size is 'dataSize', for example, dataSize = 1920 * |
108 | | - * 1080 * 2*sizeof(float) (1920 * 1080 represents the image resolution, and 2 represents two LUTs, one for x-coordinate and one for y-coordinate). |
109 | | - * @param dataSize input data size |
110 | | - * @param xyTables output xy tables |
111 | | - * |
112 | | - * @return bool Transform result |
113 | | - */ |
114 | | - static bool transformationInitXYTables(const OBCalibrationParam calibrationParam, const OBSensorType sensorType, float *data, uint32_t *dataSize, |
115 | | - OBXYTables *xyTables); |
| 119 | + /** |
| 120 | + * @brief Init transformation tables |
| 121 | + * |
| 122 | + * @param calibrationParam Device calibration param,see pipeline::getCalibrationParam |
| 123 | + * @param sensorType sensor type |
| 124 | + * @param data input data,needs to be allocated externally.During initialization, the external |
| 125 | + * allocation size is 'dataSize', for example, dataSize = 1920 * 1080 * 2*sizeof(float) (1920 * |
| 126 | + * 1080 represents the image resolution, and 2 represents two LUTs, one for x-coordinate and one |
| 127 | + * for y-coordinate). |
| 128 | + * @param dataSize input data size |
| 129 | + * @param xyTables output xy tables |
| 130 | + * |
| 131 | + * @return bool Transform result |
| 132 | + */ |
| 133 | + static bool transformationInitXYTables(const OBCalibrationParam calibrationParam, |
| 134 | + const OBSensorType sensorType, float *data, |
| 135 | + uint32_t *dataSize, OBXYTables *xyTables); |
116 | 136 |
|
117 | | - /** |
118 | | - * @brief Transform depth image to point cloud data |
119 | | - * |
120 | | - * @param xyTables input xy tables,see CoordinateTransformHelper::transformationInitXYTables |
121 | | - * @param depthImageData input depth image data |
122 | | - * @param pointCloudData output point cloud data |
123 | | - * |
124 | | - */ |
125 | | - static void transformationDepthToPointCloud(OBXYTables *xyTables, const void *depthImageData, void *pointCloudData); |
| 137 | + /** |
| 138 | + * @brief Transform depth image to point cloud data |
| 139 | + * |
| 140 | + * @param xyTables input xy tables,see CoordinateTransformHelper::transformationInitXYTables |
| 141 | + * @param depthImageData input depth image data |
| 142 | + * @param pointCloudData output point cloud data |
| 143 | + * |
| 144 | + */ |
| 145 | + static void transformationDepthToPointCloud(OBXYTables *xyTables, const void *depthImageData, |
| 146 | + void *pointCloudData); |
126 | 147 |
|
127 | | - /** |
128 | | - * @brief Transform depth image to RGBD point cloud data |
129 | | - * |
130 | | - * @param xyTables input xy tables,see CoordinateTransformHelper::transformationInitXYTables |
131 | | - * @param depthImageData input depth image data |
132 | | - * @param colorImageData input color image data (only RGB888 support) |
133 | | - * @param pointCloudData output RGBD point cloud data |
134 | | - * |
135 | | - */ |
136 | | - static void transformationDepthToRGBDPointCloud(OBXYTables *xyTables, const void *depthImageData, const void *colorImageData, void *pointCloudData); |
| 148 | + /** |
| 149 | + * @brief Transform depth image to RGBD point cloud data |
| 150 | + * |
| 151 | + * @param xyTables input xy tables,see CoordinateTransformHelper::transformationInitXYTables |
| 152 | + * @param depthImageData input depth image data |
| 153 | + * @param colorImageData input color image data (only RGB888 support) |
| 154 | + * @param pointCloudData output RGBD point cloud data |
| 155 | + * |
| 156 | + */ |
| 157 | + static void transformationDepthToRGBDPointCloud(OBXYTables *xyTables, const void *depthImageData, |
| 158 | + const void *colorImageData, void *pointCloudData); |
137 | 159 | }; |
138 | 160 | } // namespace ob |
0 commit comments