Giter VIP home page Giter VIP logo

realsense_raspberry_pi4's Introduction

librealsense on a Raspberry Pi 4

A step by step instruction for installing librealsense on a Raspberry Pi 4, or more specifically pyrealsense.

Credit goes to datasith, who also made a tutorial about this.

This repository can be understood as a fork from his wiki entry.

Hardware

  • Raspberry Pi 4 Model B 8GB Rev 1.4 B
  • 64 GB SanDisk SD card
  • Intel Realsense D435

Operating System

  • Install Raspberry Pi OS 32-bit installed via the Raspberry Pi Imager.
  • If you're doing this in headless mode, the Imager program allows you to conviniently set up WiFi and SSH access.

Prerequisites

  • Start with updating, upgrading, and installing dependencies and tools:
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install -y automake libtool cmake libusb-1.0-0-dev libx11-dev xorg-dev libglu1-mesa-dev libssl-dev clang llvm libatlas-base-dev python3-opencv
  • Expand the filesystem by selecting Advanced Options > Expand Filesystem, and select yes to rebooting:
sudo raspi-config
  • (not necessary on the 8 GB Raspberry) Increase swap to 2GB by changing the file below to CONF_SWAPSIZE=2048:
sudo nano /etc/dphys-swapfile
  • (not necessary on the 8 GB Raspberry) Apply the change:
sudo /etc/init.d/dphys-swapfile restart swapon -s
  • Clone the realsense repo and create a new udev rule:
cd ~
git clone https://github.com/IntelRealSense/librealsense.git
cd librealsense
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/ 
  • Apply the change (needs to be run by root):
sudo su
udevadm control --reload-rules && udevadm trigger
exit
  • Add the following lines to the end of your .bashrc file (some of these are first needed at later steps):
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=3

export PYTHONPATH=$PYTHONPATH:/usr/local/lib:/home/pi/librealsense/build/wrappers/python
  • Apply the change:
source ~/.bashrc

Installation

  • Install protobuf โ€” Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data:
cd ~
git clone --depth=1 -b v3.10.0 https://github.com/google/protobuf.git
cd protobuf
./autogen.sh
./configure
make -j4
sudo make install
cd python
export LD_LIBRARY_PATH=../src/.libs
python3 setup.py build --cpp_implementation 
python3 setup.py test --cpp_implementation
sudo python3 setup.py install --cpp_implementation
sudo ldconfig
protoc --version # libprotoc 3.10.0

(Running the python tests might throw errors, but the installation still worked fine for me in the end.)

  • Install libtbb-dev parallelism library for C++:
cd ~
wget https://github.com/PINTO0309/TBBonARMv7/raw/master/libtbb-dev_2018U2_armhf.deb
sudo dpkg -i ~/libtbb-dev_2018U2_armhf.deb
sudo ldconfig
rm libtbb-dev_2018U2_armhf.deb
  • Change default C/C++ compiler to clang (#9962)
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
  • Install RealSense SDK librealsense:
cd ~/librealsense
mkdir  build  && cd build
cmake .. -DBUILD_EXAMPLES=true -DCMAKE_BUILD_TYPE=Release -DFORCE_LIBUVC=true -DOTHER_LIBS="-latomic"
make -j4
sudo make install

(The DOTHER_LIBS flag might not be required, but I had it from previous attempts to fixing this and it worked so I'm leaving it)

  • Install RealSense SDK pyrealsense2 Python bindings for librealsense:
cd ~/librealsense/build
cmake .. -DBUILD_PYTHON_BINDINGS=bool:true -DPYTHON_EXECUTABLE=$(which python3)
make -j4
sudo make install
  • Change the default compiler back to gcc
unset CC
unset CXX

Testing

I've included an example script for using the pyrealsense2 library. Tested with a D435.

  • Download the example python script from this repo
cd ~
wget https://raw.githubusercontent.com/mathklk/realsense_raspberry_pi4/master/example.py
chmod +x example.py
  • Run the script (requires a desktop environment to show the image)
./example.py

realsense_raspberry_pi4's People

Contributors

mathklk avatar

Stargazers

 avatar  avatar  avatar  avatar Juan E. Ojeda avatar  avatar

Watchers

TexnoMann avatar Juan E. Ojeda avatar  avatar

Forkers

mrswener

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.