相比能看到这里的家人们肯定都会遇到,结构光关闭不了的问题!!!(也就是那个白点点。)
实际上,直接遮住中间的相机就ok啦!
就这!
如果感觉有用,麻烦点个赞哦!!!!
附送一段代码:调用左右相机的!!!
import pyrealsense2 as rs import numpy as np import cv2 import time counter = 0 # 若要保存到其他文件夹,修改此路径 folder = 'left/' # time.time() def shot(pos, frame): global counter path = folder + pos + "_" + str(counter) + ".png" cv2.imwrite(path, frame) print("snapshot saved into: " + path) pipeline = rs.pipeline() config = rs.config() # 配置深度和颜色流 # 10、15或者30可选,20或者25会报错,其他帧率未尝试 # 配置颜色相机 config.enable_stream(rs.stream.color, 848, 480, rs.format.bgr8, 15) # 配置红外相机 config.enable_stream(rs.stream.infrared, 1, 848, 480, rs.format.y8, 15) config.enable_stream(rs.stream.infrared, 2, 848, 480, rs.format.y8, 15) # 配置深度图像 print(1) print(2) config.enable_stream(rs.stream.depth, 848, 480, rs.format.z16, 15) # Start streaming profile = pipeline.start(config) config.disable_stream(rs.stream.infrared) # 创建对齐对象, rs.align 允许我们将深度帧与其他帧对齐, "align_to" 是计划对其深度帧的流类型 align_to = rs.stream.color align = rs.align(align_to) try: while True: frames = pipeline.wait_for_frames() # 将深度框与颜色框对齐 aligned_frames = align.process(frames) # 获取对齐帧 color_frame = aligned_frames.get_color_frame() if not color_frame: continue color_frame = np.asanyarray(color_frame.get_data()) # cv2.imshow('2 color', color_frame) # left frames left_frame = frames.get_infrared_frame(1) if not left_frame: continue left_frame = np.asanyarray(left_frame.get_data()) cv2.imshow('3 left_frame', left_frame) # right frames right_frame = frames.get_infrared_frame(2) if not right_frame: continue right_frame = np.asanyarray(right_frame.get_data()) cv2.imshow('4 right_frame', right_frame) c = cv2.waitKey(1) # 如果按下ESC则关闭窗口(ESC的ascii码为27),同时跳出循环 if c == 27: cv2.destroyAllWindows() break if c == ord('t'): # 默认保存五张图片,如果不需要保存某图像把对应那行代码注释掉即可 shot('left_shot', left_frame) shot('right_shot', right_frame) counter += 1 finally: # Stop streaming pipeline.stop()
具体的使用matlab的标注办法如此链接:哈哈哈哈
这个大佬讲的巨好!!!!