4.2 彩色点云
至于彩色点云,在同一台机器上,执行前面的示例大约需要36.263秒 。通过应用向量化,运行时间减少到0.722秒 。
# compute indices:jj = np.tile(range(width), height)ii = np.repeat(range(height), width)# Compute constants:xx = (jj - CX_DEPTH) / FX_DEPTHyy = (ii - CY_DEPTH) / FY_DEPTH# transform depth image to vector of z:length = height * widthz = depth_image.reshape(length)# compute point cloudpcd = np.dstack((xx * z, yy * z, z)).reshape((length, 3))cam_RGB = np.apply_along_axis(np.linalg.inv(R).dot, 1, pcd) - np.linalg.inv(R).dot(T)xx_rgb = ((cam_RGB[:, 0] * FX_RGB) / cam_RGB[:, 2] + CX_RGB + width / 2).astype(int).clip(0, width - 1)yy_rgb = ((cam_RGB[:, 1] * FY_RGB) / cam_RGB[:, 2] + CY_RGB).astype(int).clip(0, height - 1)colors = rgb_image[yy_rgb, xx_rgb]5. 结论
在本教程中,我们学习了如何从 RGB-D 数据来计算点云 。
推荐阅读
- python小程序轻松实现九宫格高“逼格”圈照,快来试一试
- Python生成二维码之segno模块
- 现实世界模型、薛定谔的猫和神经网络之间的联系及Python示例
- python日志包从头到尾讲清楚
- 十年 Python 程序员,初次尝试 Rust:“非常优秀!”
- python代码提速有哪些方法
- Python 获取上市公司利润表数据
- 连信是什么?
- python读写json文件
- 使用python selenium模拟登陆163并发送邮件
