【发布时间】:2023-03-21 05:46:01
【问题描述】:
我有一个关于机器人映射的研究想法。基本上,最终目标是使用适中的单目相机(售价 20-50 美元)并创建 3D 占用网格图(有一个用 c++ 编写的流行库,称为 Octomap)。为了做到这一点,我建议自己采取以下步骤:
获取 rgb 图像(来自视频)并使用卷积神经网络转换为深度图像。这部分完成了。
获取原始 rgb 图像和创建的深度图像并转换为点云。
获取点云并将其转换为 3D 占用网格图。
所以对于第 2 步,我有点困惑,无论我做对还是错。我已经使用了这个代码,它是一个开源的:
import argparse
import sys
import os
from PIL import Image
focalLength = 938.0
centerX = 319.5
centerY = 239.5
scalingFactor = 5000
def generate_pointcloud(rgb_file,depth_file,ply_file):
rgb = Image.open(rgb_file)
depth = Image.open(depth_file).convert('I')
if rgb.size != depth.size:
raise Exception("Color and depth image do not have the same
resolution.")
if rgb.mode != "RGB":
raise Exception("Color image is not in RGB format")
if depth.mode != "I":
raise Exception("Depth image is not in intensity format")
points = []
for v in range(rgb.size[1]):
for u in range(rgb.size[0]):
color = rgb.getpixel((u,v))
Z = depth.getpixel((u,v)) / scalingFactor
print(Z)
if Z==0: continue
X = (u - centerX) * Z / focalLength
Y = (v - centerY) * Z / focalLength
points.append("%f %f %f %d %d %d 0\n"%
我认为points 是实际存储点云的列表,对吗?
所以我要问的一个大问题是,使用深度学习算法创建 RGB 图像和深度图像是否可以使用上面的代码转换为点云?
【问题讨论】:
-
我想你应该没问题,只要你知道缩放因子和焦距。
标签: python point-cloud-library