slam之使用realsense T265得到深度图

使用realsense T265得到深度图

研究realsense 的github发现了其在librealsense中已经放好了wrapper,该wrapper中的python部分已经做好了使用T265获得深度图的例程:t265_stereo.py,下面给出获得深度图的过程。

所需条件

系统为ubuntu16.04,需要realsenseT265相机,python3,opencv(这里默认大家安装好了realsense的SDK,如果未安装,可以查看https://blog.csdn.net/weixin_44386661/article/details/100699985)

首先配置环境(一步步的来)

1.安装python3的虚拟环境支持
apt-get install python3-venv
2.创建一个虚拟环境
python3 -m venv py3librs
3. 进入虚拟环境
source py3librs/bin/activate
4. 安装python虚拟环境下的opencv(这个不大,很快就下载完成)
pip install opencv-python
5.安装pyrealsense2
pip install pyrealsense2

获取深度图

重新开启一个终端
1.进入虚拟环境
source py3librs/bin/activate
2.获取深度图
python3 t265_stereo.py

这里可能会报错如下:

可能出现的错误
这是由于安装了ROS导致系统会默认去找ros中的python的cv2库

所以我们需要在.bashrc中自己设置python3.5中库的路径,
首先在一个终端输入:
sudo gedit .bashrc
然后在.bashrc文件的最后一行加入:
export PYTHONPATH="/home/wyt/py3librs/lib/python3.5/site-packages":$PYTHONPATH
这里的路径需要自己去查,每个人的都不一样.只要找到自己的py3librs/lib/python3.5/site-packages的路径,替换掉我的那个即可.

最后可得到深度图如下:

在这里插入图片描述将t265_stereo.py保存到home下即可,也可以随便改名字.
t265_stereo的程序如下:

#!/usr/bin/python
# -*- coding: utf-8 -*-
## License: Apache 2.0. See LICENSE file in root directory.
## Copyright(c) 2019 Intel Corporation. All Rights Reserved.
# Python 2/3 compatibility
from __future__ import print_function

"""
This example shows how to use T265 intrinsics and extrinsics in OpenCV to
asynchronously compute depth maps from T265 fisheye images on the host.
T265 is not a depth camera and the quality of passive-only depth options will
always be limited compared to (e.g.) the D4XX series cameras. However, T265 does
have two global shutter cameras in a stereo configuration, and in this example
we show how to set up OpenCV to undistort the images and compute stereo depth
from them.
Getting started with python3, OpenCV and T265 on Ubuntu 16.04:
First, set up the virtual enviroment:
$ apt-get install python3-venv  # install python3 built in venv support
$ python3 -m venv py3librs      # create a virtual environment in pylibrs
$ source py3librs/bi
  • 3
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值