码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2019-03-18 20:03:08      阅读:383      评论:0      收藏:0      [点我收藏+]

标签:register   rar   nal   指南   mkdir   tps   win   start   orm   

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

1、Register the servers 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 cant 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 its 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 环境配置指南

标签:register   rar   nal   指南   mkdir   tps   win   start   orm   

原文地址:https://www.cnblogs.com/z1141000271/p/10554341.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!