我有一个研究机器人地图的想法。基本上,最终目标是使用一个中等大小的单目相机(20-50美元)并创建一个三维占用网格地图(有一个用c++编写的流行库Octomap)。为此,我建议自己采取以下步骤:
从视频中提取一个rgb图像,并使用卷积神经网络将其转换为深度图像。这一部分完成了。
获取原始rgb图像和创建的深度图像并转换为点云。
获取点云并将其转换为三维占用栅格地图。
所以对于第二步,我有点困惑,是我做对了还是错了。我采用了以下代码,这是一个开源代码:
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"%
{我认为云点存储的是什么?在
所以我要问的一个大问题是,使用深度学习算法创建的RGB图像和深度图像是否可以使用上面的代码转换为点云?在
目前没有回答
相关问题 更多 >
编程相关推荐