【Intel® RealSense™ SDK 2.0 】在【Linux】环境配置记录

【Intel® RealSense™ SDK 2.0 】在【Linux】环境配置记录

Intel® RealSense™ SDK 2.0 官网

系统环境

ubuntu 18.04

建conda环境

conda create -n real_sense python=3.7
conda activate real_sense

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple scikit-build
pip3 install opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install numpy
pip3 install PyQt5 -i https://pypi.douban.com/simple
pip3 install PyQt5-tools -i https://pypi.douban.com/simple

Real_Sense SDK 2.0 Ubuntu X86/AMD64 的 Debian 安装包

官方Linux 发行版SDK安装指南
Linux Ubuntu 编译安装

  1. 使 Ubuntu 保持最新:

    更新 Ubuntu 发行版,包括获取最新的稳定内核:
    sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade

  2. 安装软件包:
    注册服务器的公钥:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE

    如果仍然无法检索到公钥,请检查并指定代理设置:export http_proxy=“http://:”
    ,然后重新运行该命令。请参阅以下链接中的其他方法。

  3. 将服务器添加到存储库列表中:

    sudo add-apt-repository “deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main” -u

    安装库(如果升级包,请参阅下面的部分):

    sudo apt-get install librealsense2-dkms
    sudo apt-get install librealsense2-utils

    以上两行将部署 librealsense2 udev 规则,构建和激活内核模块,运行时库和可执行演示和工具。

    可选择安装开发人员和调试包:安装包后,您可以

    sudo apt-get install librealsense2-dev
    sudo apt-get install librealsense2-dbg

    重新连接英特尔实感深度摄像头并运行:realsense-viewer以验证安装。

Python库的安装和调用

官方Python Wrapper

pip install pyrealsense2

官方例程(已修改)

	# First import the library
	import pyrealsense2 as rs
	import numpy as np
	# Create a context object. This object owns the handles to all connected realsense devices
	pipeline = rs.pipeline()
	pipeline.start()
	
	try:
	    while True:
	        # Create a pipeline object. This object configures the streaming camera and owns it's handle
	        frames = pipeline.wait_for_frames()
	        depth = frames.get_depth_frame()
	        depth_data = depth.as_frame().get_data()
	        np_image = np.asanyarray(depth_data)
	
	        if not depth:
	            continue
	
	        # Print a simple text-based representation of the image, by breaking it into 10x20 pixel regions and approximating the coverage of pixels within one meter
	        coverage = [0] * 64
	        for y in range(480):
	            for x in range(640):  # 每行检测640个点
	                dist = depth.get_distance(x, y)  # 在给定的像素处提供以米为单位的深度
	                if 0 < dist and dist < 1:
	                    coverage[x // 10] += 1  # x上每10个点对应一个要打印的深度记录
	
	            if y % 20 == 19:  # 每20个y打印一次
	                line = ""
	                for c in coverage:
	                    line += " .:nhBXWW"[c // 25]  # 根据深度记录打印不同字符
	                coverage = [0] * 64
	                print(line)
	
	finally:
	    pipeline.stop()
	```
	
## 参考文献:
[Ubuntu 18.04 ———(Intel RealSense D435i)安装相机的驱动librealsense + realsense-ros](https://blog.csdn.net/qq_38364548/article/details/124784454)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值