Skip to content

Commit e1b106c

Browse files
committed
Update: Fixed the issue of point cloud distortion in femto bolt
1 parent e13545c commit e1b106c

File tree

4 files changed

+241
-200
lines changed

4 files changed

+241
-200
lines changed

orbbec_camera/SDK/include/libobsensor/hpp/Utils.hpp

Lines changed: 137 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -6,133 +6,155 @@
66
#pragma once
77

88
#include "Types.hpp"
9+
#include "Frame.hpp"
910

1011
namespace ob {
1112
class Device;
1213

1314
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);
2831

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);
4349

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);
5970

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);
7386

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);
88104

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);
101118

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);
116136

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);
126147

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);
137159
};
138160
} // namespace ob

orbbec_camera/include/orbbec_camera/constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const float ROS_DEPTH_SCALE = 0.001;
103103
const int32_t FEMTO_OW_PID = 0x0638;
104104
const int32_t FEMTO_BOLT_PID = 0x066b;
105105
const int32_t FEMTO_LIVE_PID = 0x0668;
106+
const uint32_t FEMTO_MEGA_PID = 0x0669;
106107
const int32_t FEMTO_PID = 0x0635;
107108
const int32_t ASTRA_PLUS_PID = 0x0636;
108109
const int32_t ASTRA_PLUS_S_PID = 0x0637;

orbbec_camera/include/orbbec_camera/ob_camera_node.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ class OBCameraNode {
139139
const rcl_interfaces::msg::ParameterDescriptor& parameter_descriptor =
140140
rcl_interfaces::msg::ParameterDescriptor()); // set and get parameter
141141

142-
~OBCameraNode();
142+
~OBCameraNode() noexcept;
143143

144-
void clean();
144+
void clean() noexcept;
145145

146146
void startStreams();
147147

@@ -538,5 +538,13 @@ class OBCameraNode {
538538
bool retry_on_usb3_detection_failure_ = false;
539539
std::atomic_bool is_camera_node_initialized_{false};
540540
int laser_energy_level_ = -1;
541+
ob::PointCloudFilter depth_point_cloud_filter_;
542+
ob::PointCloudFilter colored_point_cloud_filter_;
543+
std::optional<OBCalibrationParam> calibration_param_;
544+
std::optional<OBXYTables> xy_tables_;
545+
float* xy_table_data_ = nullptr;
546+
uint32_t xy_table_data_size_ = 0;
547+
uint8_t* rgb_pint_cloud_buffer_ = nullptr;
548+
uint32_t rgb_pint_cloud_buffer_size_ = 0;
541549
};
542550
} // namespace orbbec_camera

0 commit comments

Comments
 (0)