open3d学习系列之1读取深度图和彩色图生成点云数据
import pyrealsense2 as rs
import numpy as np
import cv2
import matplotlib.pyplot as plt
import open3d as o3d
img_f = 'abc.png'
color_image = cv2.imread(img_f)
cv2.imshow('img', color_image)
cv2.waitKey(1)
depth_image = np.load(img_f.replace('.png', '.npz'))['data']
o3d_color = o3d.geometry.Image(color_image)
o3d_depth = o3d.geometry.Image(depth_image)
rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(o3d_color, o3d_depth,
depth_scale=1000.0,
depth_trunc=1000.0)
pinhole_camera_intrinsic = o3d.camera.PinholeCameraIntrinsic(
intrinsics.width, intrinsics.height,
intrinsics.fx, intrinsics.fy,
intrinsics.ppx, intrinsics.ppy
)
tmp = o3d.geometry.PointCloud.create_from_rgbd_image(
rgbd_image,
pinhole_camera_intrinsic
)
o3d.io.write_point_cloud("1_open3d.ply", o3d_result)