原理
在机器人及其他应用中,除了传统的RGB三通道相机以外,常常还会配置有深度传感器。比较常用的有Kinect,Lidar等等。博主前段时间被研究所导师布置了一个用深度图(depth image)和RGB图片来生成点云的任务。一开始谷歌百度了很久发现居然没有python的解法。实际上这是一个非常简单的问题,只要计算一下二维到三维的映射就可以了。
我自己写了一个转换函数可以直接生成点云了,原始repo在:Github代码库
代码
from PIL import Image
import pandas as pd
import numpy as np
from open3d import read_point_cloud, draw_geometries
import time
class point_cloud_generator():
def __init__(self, rgb_file, depth_file, pc_file, focal_length, scalingfactor):
self.rgb_file = rgb_file
self.depth_file = depth_file
self.pc_file = pc_file
self.focal_length = focal_length
self.scalingfactor = scalingfactor
self.rgb = Image.open(rgb_file)
self.depth = Image.open(depth_file).convert('I')
self.width = self.rgb.size[0]
self.height = sel

本文介绍如何利用深度图和RGB图像生成三维点云,主要应用于机器人和其他领域。作者分享了自己编写的Python转换函数,并提供了一个简单的坐标转换原理链接,读者可以参考该原理并结合提供的代码实现点云生成。
最低0.47元/天 解锁文章
1万+





