Intel realSense ubuntu 16.04+python 环境配置指南,ubuntu怎么安装python,1. 安装libre


1. 安装librealsense2-dkms 以及librealsense2-utils

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" -uUbuntu 18 LTS:sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo bionic main" -u3、Install the libraries (see section below if upgrading packages):sudo apt-get install librealsense2-dkmssudo apt-get install librealsense2-utilsThe 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是这个样子~

技术图片

2. 配置warpper----python环境

下载https://github.com/IntelRealSense/librealsense项目到本地

  

Building From Source Ubuntu 14.04/16.04 LTS Ensure apt-get is up to date1、sudo apt-get update && sudo apt-get upgradeNote: Use sudo apt-get dist-upgrade, instead of sudo apt-get upgrade, in case you have an older Ubuntu 14.04 versionInstall 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-devNote: The project will only use Python 2 if it can‘t use Python 3Run 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:trueNote: 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 install4、update your PYTHONPATH environment variable to add the path to the pyrealsense libraryexport PYTHONPATH=$PYTHONPATH:/usr/local/lib

Alternatively, copy the build output (librealsense2.so and pyrealsense2.so) next to your script.Note: Python 3 module filenames may contain additional information, e.g. pyrealsense2.cpython-35m-arm-linux-gnueabihf.so)

Python 接口使用的例子:

# First import the libraryimport pyrealsense2 as rstry:    # Create a context object. This object owns the handles to all connected realsense devices    pipeline = rs.pipeline()    pipeline.start()    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()        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 xrange(480):            for x in xrange(640):                dist = depth.get_distance(x, y)                if 0 < dist and dist < 1:                    coverage[x/10] += 1            if y%20 is 19:                line = ""                for c in coverage:                    line += " .:nhBXWW"[c/25]                coverage = [0]*64                print(line)

 

Intel realSense ubuntu 16.04+python 环境配置指南

评论关闭