ubutnu16.04下Intel Realsense D435驱动的安装和python环境的配置
一、 Intel Realsense D435驱动的安装
普遍操作:这里就复制别人的:
1、Register the server's public key:
sudo apt-key adv --keyserver keys.gnupg.net --recv-key C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C8B3A55A6F3EFCDE
(In case the public key still cannot be retrieved, check and specify proxy settings: export http_proxy="http://<proxy>:<port>"
, and rerun the command. See additional methods in the following link.)
2、Add the server to the list of repositories:
Ubuntu 16 LTS:
sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo xenial main" -u
Ubuntu 18 LTS:
sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo bionic main" -u
3、Install the libraries (see section below if upgrading packages):
sudo apt-get install librealsense2-dkms
sudo apt-get install librealsense2-utils
The above two lines will deploy librealsense2 udev rules, build and activate kernel modules, runtime library and executable demos and tools.
Reconnect the Intel RealSense depth camera and run: realsense-viewer to verify the installation.
配置好之后,在命令行中输入:
realSense-viewer
出现以下界面就是驱动安装成功
二、SDK安装+python环境配置
首先下载SDK包:https://github.com/IntelRealSense/librealsense
Building From Source Ubuntu 14.04/16.04 LTS Ensure apt-get is up to date
1、sudo apt-get update && sudo apt-get upgrade
Note: Use sudo apt-get dist-upgrade, instead of sudo apt-get upgrade, in case you have an older Ubuntu 14.04 version
Install Python and its development files via apt-get (Python 2 and 3 both work)
2、sudo apt-get install python python-dev or sudo apt-get install python3 python3-dev
Note: The project will only use Python 2 if it can't use Python 3
Run the top level CMake command with the following additional flag -DBUILD_PYTHON_BINDINGS=bool:true:
3、mkdir build
cd build
cmake ../ -DBUILD_PYTHON_BINDINGS=bool:true -DPYTHON_EXECUTABLE=python的执行路径
Note: To force compilation with a specific version on a system with both Python 2 and Python 3 installed, add the following flag to CMake command: -DPYTHON_EXECUTABLE=[full path to the exact python executable]
(cmake常用套路了)
make -j4
sudo make install
4、update your PYTHONPATH environment variable to add the path to the pyrealsense library
export PYTHONPATH=$PYTHONPATH:/usr/local/lib
安装成功后,打开python输入 import pyrealsense2,发现还是没有该模块。
接下来需要自己安装:
pip3 install pyrealsense2
安装完成后,再打开python,输入可以
可以使用下面的代码进行测试:
import pyrealsense2 as rs
import cv2
import numpy as np
def show(img,res='res'):
cv2.imshow(res,img)
cv2.waitKey(0)
cv2.destroyAllWindows()
pipeline = rs.pipeline()
pipeline.start()
while True:
frames = pipeline.wait_for_frames()
depth = frames.get_depth_frame()
img = frames.get_color_frame()
img = np.asanyarray(img.get_data())
img1 = cv2.cvtColor(img,cv2.COLOR_RGB2BGR)
dst = np.hstack((img,img1))
cv2.imshow('res',dst)
if cv2.waitKey(10) &0xff == ord('q'):
break