Intel Realsense d435 使用python对深度图进行预处理

Intel Realsense d435 使用python对深度图进行预处理

本文中主要翻译一下一篇关于深度图预处理过滤器的内容,后面还会有关于距离测量的。
原文中的图像显示,是使用matplotlib.pyplot工具,在本文中,使用opencv来显示深度图》
首先常规操作导入包:

import cv2
import numpy as np
import pyrealsense2 as rs

获取我们所需要的图像,通过摄像头或者本地都可以

pipe = rs.pipeline()
cfg = rs.config()
cfg.enable_stream(rs.stream.depth,640,480,rs.format.z16,30)
cfg.enable_stream(rs.stream.color,640,480,rs.format.bgr8,30)
profile = pipe.start(cfg)

try:
    while True:
        frame = pipe.wait_for_frames()
        depth_frame = frame.get_depth_frame()
        print('capture success')
        if cv2.waitKey(10)&0xff == ord('q'):
            break

finally:
    pipe.stop()

获取成功,在终端打印信息

一、深度图像的可视化

使用pyrealsense2库中提供的colorizer来将图像中的深度值转为可以显示的形式:

colorizer = rs.colorizer()
colorizer_depth = np.asanyarray(colorizer.colorize(depth_frame).get_data()
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值