我有一个关于机器人地图的研究想法。基本上,最终目标是使用一个中等的单目相机(售价20-50美元),并创建一个3D占用率网格地图(有一个用c++编写的流行库,名为Octomap)。为了做到这一点,我建议自己采取以下步骤:
因此,对于第二步,我有点困惑,无论我做的是对还是错。我使用了这段代码,它是一个开放源代码:
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图像和深度图像,是否可以使用上面的代码将其转换为点云?
发布于 2021-02-05 17:19:12
如果你能妥善处理RGB和深度图像比例,你会没事的。最后一点云属性可能类似于(x,y,z,r,g,b)。
https://stackoverflow.com/questions/52319922
复制相似问题