文章目录:

1 RealSense D435摄像头介绍

英特尔® 实感™ D435 在我们推出的所有摄像头中视场最大

,深度传感器上配置全局快门,是快速移动应用的理想选择。

1.1 D435外观及内部构造

1、外观

2、内部构造

1.2 D435的参数规格

1、使用场景和范围

  • 使用环境:室内 / 室外
  • 最大范围:约10米

2、深度

  • 深度视场(FOV):87°±3° × 58°±1° × 95°±3°
  • 最小深度距离:0.105米
  • 深度输出分辨率和帧率:高达 1280 × 720 的主动立体深度分辨率。高达 90 帧/秒。

3、RGB

  • RGB 传感器分辨率:1920 × 1080
  • RGB 帧率:30
  • RGB 传感器 FOV (H × V × D):69.4° × 42.5° × 77° (±3°)

1.3 D435应用

英特尔® 实感™ 深度摄像头 D435 是一款立体追踪解决方案,可为各种应用提供高质量深度。它的宽视场非常适合机器人或增强现实和虚拟现实等应用,在这些应用中,尽可能扩大场景视角至关重要。这款外形小巧的摄像头拍摄范围高达 10 米,可轻松集成到任何解决方案中,而且配置齐全,采用英特尔实感 SDK 2.0,并提供跨平台支持。

2 RealSense D435摄像头的使用

2.1 使用D435读取摄像头RGB和深度图

安装python库pyrealsense2

pip install pyrealsense2

更多pyrealsense2的python教程参考

import pyrealsense2 as rs
import numpy as np
import cv2

# Configure depth and color streams
pipeline = rs.pipeline()
config = rs.config()
# config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)

config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)

# Start streaming
pipeline.start(config)

try:
    while True:

        # Wait for a coherent pair of frames: depth and color
        frames = pipeline.wait_for_frames()
        # 深度图
        depth_frame = frames.get_depth_frame()
        # 正常读取的视频流
        color_frame = frames.get_color_frame()
        if not depth_frame or not color_frame:
            continue

        # Convert images to numpy arrays
        depth_image = np.asanyarray(depth_frame.get_data())
        color_image = np.asanyarray(color_frame.get_data())
        # print(f"depth_image shape: {depth_image.shape} color_image shape: {color_image.shape}")
        print(f"depth_image value: {depth_image}")   # 里面0值很多,还有很多1900左右的值      300mm 单位是毫米=30厘米=0.3米
        # depth_image shape: (480, 640) color_image shape: (480, 640, 3)
        # 深度图是单通道  颜色图是三通道的

        # Apply colormap on depth image (image must be converted to 8-bit per pixel first)
        # 在深度图像上应用colormap(图像必须先转换为每像素8位)
        depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)

        # Stack both images horizontally
        images = np.hstack((color_image, depth_colormap))

        # Show images
        cv2.namedWindow('RealSense', cv2.WINDOW_AUTOSIZE)
        cv2.imshow('RealSense', images)
        cv2.waitKey(1)

finally:

    # Stop streaming
    pipeline.stop()

3 使用D435做目标检测和距离测量

先简单说明我如何做检测到目标的距离检测的:

  • 1)首先使用目标检测方法,检测要检测的目标
  • 2)检测到目标之后,获取目标bbox的中心坐标
  • 3)使用D435获取深度画面的深度信息
  • 1)首先使用目标检测方法,检测要检测的目标
  • 2)检测到目标之后,获取目标bbox的中心坐标
  • 3)使用D435获取深度画面的深度信息

下面是我检测人之后,并获取人距离摄像头的距离,结果如下:

(由于CSDN限制上传图片大小,我就裁剪了很短的一段gif,大家凑合看)

检测的问题,如果目标bbox的中心点,没有object上,这样获取到的距离就是背景上,这样就是不准确的,目前想到的方式就是通过分割的方式,然后获取分割目标区域的重心

参考 : https://blog.csdn.net/glb562000520/article/details/17264151 # ToF相机介绍
参考:https://baike.baidu.com/item/%E7%A7%92/2924586

参考:https://blog.csdn.net/zhouyy858/article/details/102658020 # 超声波雷达
参考:https://blog.csdn.net/zhouyy858/article/details/100360829 # 目标跟踪

欢迎大家关注笔者,你的关注是我持续更博的最大动力



原创文章,转载告知,盗版必究

微信:suihailiang0816
QQ:931762054
wx公众号:仰望星空的小随