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

Posted 不搞事情和咸鱼有什么区别

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Intel realSense ubuntu 16.04+python 环境配置指南相关的知识,希望对你有一定的参考价值。

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" -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是这个样子~

 

 

 

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

  下载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 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

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 library
import pyrealsense2 as rs

try:
    # 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 环境配置指南的主要内容,如果未能解决你的问题,请参考以下文章

转Intel RealSense(实感技术)概览

ROS实验笔记之——Intel Realsense l515激光相机的使用

实感相机-Intel Realsense Camera

Intel RealSense的使用范围是多少

intel realsense 3d camera 驱动和win7兼容吗

Intel Realsense Depth Quality Tool 相关参数