一、第一种实现代码
Python
import sys
import cv2
import pyrealsense2 as rs
import numpy as np
import keyboard
import open3d as o3d
import os
if __name__ == "__main__":
output_folder = 'output_data/'
os.makedirs(output_folder, exist_ok=True)
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 848, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 848, 480, rs.format.bgr8, 30)
# Start streaming
pipeline.start(config)
# 深度图像向彩色对齐
align_to_color = rs.align(rs.stream.color)
i = 0
try:
while True:
pc = rs.pointcloud()
# Wait for a coherent pair of frames: depth and color