intel realsense系列相机关于深度图与rgb图对齐失败,问题总结

 前几天贪便宜,淘了一个二手的d435相机用来搞6d姿态估计,在使用objectdatasettools工具的recode2.py工具生成linemod数据集的rgb与depth图片,进行到 compute_gt_poses.py时报了一个错

Full registration ...
registration::PoseGraph with 0 nodes and 0 edges.
  0%|                                                                                          | 0/301 [00:00<?, ?it/s][Open3D WARNING] [KDTreeFlann::SetRawData] Failed due to no data.
[Open3D WARNING] [KDTreeFlann::SetRawData] Failed due to no data.
  0%|                                                                                          | 0/301 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "compute_gt_poses.py", line 353, in <module>
    pose_graph = full_registration(path, max_correspondence_distance_coarse,
  File "compute_gt_poses.py", line 182, in full_registration
    transformation_icp, information_icp = icp(
  File "C:\Users\szz\Desktop\ObjectDatasetTools-master\registration.py", line 50, in icp
    icp_coarse = registration.registration_icp(source, target,
RuntimeError: [Open3D ERROR] TransformationEstimationPointToPlane and TransformationEstimationColoredICP require pre-computed normal vectors.

这是因为数据集对齐失败,导致计算时深度图缺失而引起的,我通过输出对齐后的深度图数据,显示全是0的数组,由此推测,应该是对齐的变换矩阵为零导致的,输出的深度图如下图所示。

而对齐变换矩阵与相机的参数有关,不出所料输出参数如下所示

Rotation: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
Translation: [0.0, 0.0, 0.0]
Extrinsics from depth to color are all zeros.

这是我们可以通过intel官方提供的dynamic calibrator相机标定工具来标定相机参数。

标定工具安装路径如下

https://www.intel.com/content/www/us/en/download/645988/29618/intel-realsense-d400-series-dynamic-calibration-tool.htmlhttps://www.intel.com/content/www/us/en/download/645988/29618/intel-realsense-d400-series-dynamic-calibration-tool.html

### 方法概述 为了实现深度图RGB像的有效对齐,通常有两类主要方法:将深度图对齐RGB像或将RGB对齐深度图。在此场景下选择了前者——即把深度图调整到匹配RGB像的空间位置[^2]。 ### 对齐过程详解 #### 数据准备阶段 在处理来自特定传感器的数据前,需确认所获取的深度数据和色彩数据分别对应于`/d435/depth/image_raw`以及`/d435/color/image_raw`这两个话题。这一步骤对于后续操作至关重要,因为不同设备可能提供不同的主题名称用于发布各自类型的像流[^3]。 #### 坐标转换逻辑 核心在于通过一系列变换矩阵来建立世界坐标系中的三维点\(P_w\)其对应的彩色摄像机坐标系内投影点\(\dot{P}_{cc}\)之间的关系: \[ \dot{P}_{cc} = T_{w2c} P_w \] 这里,\(T_{w2c}\)代表从世界坐标系到彩色相机坐标系的刚体变换矩阵,该公式描述了如何利用此变换将位于任意位置的世界坐标点映射成能在二维彩色片平面(Z=1处)表示出来的像素坐标[^4]。 ### 实现步骤说明 针对上述理论,在实际编程实践中可以按照如下方式进行编码实现: ```cpp // 定义必要的头文件引入部分省略... void alignDepthToColor(const cv::Mat& depthImage, const cv::Mat& colorImage, cv::Mat& alignedDepthImage) { // 获取内外参参数并初始化校准对象 rs2::config cfg; auto pipeline_profile = pipe.start(cfg); auto device = pipeline_profile.get_device(); // 创建align对象实例化为color stream rs2::align align_to_color(RS2_STREAM_COLOR); // 执行帧同步后的对齐操作 rs2::frameset frames = pipe.wait_for_frames(); rs2::frame aligned_depth_frame = align_to_color.process(frames).get_depth_frame(); // 将结果保存回输入变量alignedDepthImage中 alignedDepthImage.create(colorImage.size(), CV_16UC1); std::memcpy(alignedDepthImage.data, (const void*)aligned_depth_frame.get_data(), sizeof(uint16_t)*alignedDepthImage.total()); } ``` 这段代码展示了怎样借助Intel RealSense SDK所提供的API完成深度图RGB像空间上的精确配准工作流程.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值