JetSon NANO 编译pyrealsense2运行D455

Intel RealSense librealsense 安装与测试指南
本文详细介绍了如何下载并安装Intel RealSense librealsense库,包括设置环境变量、编译步骤,以及常见错误解决。最后提供了一个Python示例来测试安装效果。

安装步骤

1、下载源码
下载地址: https://github.com/IntelRealSense/librealsense

$ cd librealsense
$ ./scripts/setup_udev_rules.sh
$ echo 'hid_sensor_custom' | sudo tee -a /etc/modules


2、添加环境变量

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

3、编译

$ mkdir build
$ cd build
$ cmake ../ -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_WITH_CUDA=true
$ sudo make uninstall && make clean
$ make -j4
$ sudo make install


有时候多核make的时候会报错,可选择直接单核$make

4、添加环境变量 vim ~/.bashrc,记住添加完之后source一下

export PYTHONPATH=$PYTHONPATH:/usr/local/lib:/usr/local/lib/python3.6/pyrealsense2

完成编译安装之后,可在/usr/local/lib/python3.6/pyrealsense2/目录下查看编译好的库文件

pybackend2.cpython-36m-aarch64-linux-gnu.so    
pybackend2.cpython-36m-aarch64-linux-gnu.so.2.49.0  
pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.49
pybackend2.cpython-36m-aarch64-linux-gnu.so.2  
pyrealsense2.cpython-36m-aarch64-linux-gnu.so       
pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.49.0

5、测试

import pyrealsense2 as rs
import numpy as np
import cv2

# Configure depth and color streams
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 1280, 720, rs.format.z16, 15)
config.enable_stream(rs.stream.color, 1280, 720, rs.format.bgr8, 15)

# Start streaming
pipeline.start(config)

try:
    while True:
        # Wait for a coherent pair of frames: depth and color
        frames = pipeline.wait_for_frames()
        # 深度图
        depth_frame = frames.get_depth_frame()
        # 正常读取的视频流
        color_frame = frames.get_color_frame()
        if not depth_frame or not color_frame:
            continue
        # Convert images to numpy arrays
        depth_image = np.asanyarray(depth_frame.get_data())
        color_image = np.asanyarray(color_frame.get_data())

        # Apply colormap on depth image (image must be converted to 8-bit per pixel first)
        depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)

        # Stack both images horizontally
        images = np.hstack((color_image, depth_colormap))

        # Show images
        cv2.namedWindow('RealSenseD455', cv2.WINDOW_AUTOSIZE)
        cv2.imshow('RealSenseD455', images)
        cv2.waitKey(1)

finally:

    # Stop streaming
    pipeline.stop()

6、编译过程中可能遇到的错误
1:Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the

$ sudo apt-get install libssl-dev

2:The Xinerama headers were not found

$ sudo apt-get install libsdl2-dev

3:/home/***/projects/librealsense/build/third-party/pybind11/include/pybind11/detail/common.h:124:10: fatal error: Python.h: No such file or directory,CMakeFiles/Makefile2:268: recipe for target 'wrappers/python/CMakeFiles/pybackend2.dir/all' failed

$ sudo apt-get install python3.6-dev

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Boris_LB

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值