Skip to content

Latest commit

 

History

History
223 lines (156 loc) · 4.01 KB

install-librealsense.md

File metadata and controls

223 lines (156 loc) · 4.01 KB

Installing Intel RealSense Library

Intel RealSense

Install dependencies

Start with updating, upgrading, and installing dependencies and tools:

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install \
    automake libtool cmake \
    libusb-1.0-0-dev libx11-dev \
    xorg-dev libglu1-mesa-dev

Increase the Raspberry Pi SWAP

Before the compile process, it is recommended to increase the swap space. More swap space enables to compile LibRealSense with all cores of the Raspberry Pi without having problems due to full memory.

Edit and restart the swap service:

sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=2048/g' /etc/
dphys-swapfile
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start

Install Protobuf

Download Protobuf:

cd ${HOME}
git clone --depth=1 -b v3.12.3 https://github.com/google/protobuf.git

Configure Protobuf:

cd ${HOME}/protobuf
./autogen.sh
./configure

Compile Protobuf:

make -j4

Install Protobuf:

sudo make install

Compile Protobuf for Python:

cd ${HOME}/protobuf/python
export LD_LIBRARY_PATH=../src/.libs
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=3
python3 setup.py build --cpp_implementation
sudo python3 setup.py install --cpp_implementation
sudo ldconfig
protoc --version

Install libtbb-dev parallelism library for C++

sudo apt-get install libtbb-dev

Install LibRealSense

Clone the Intel LibRealSense:

cd ${HOME}
git clone https://github.com/IntelRealSense/librealsense.git

Apply the udev rules:

cd ${HOME}/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

Modify the path by adding the following line to the .bashrc file:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
source ${HOME}/.bashrc

Build the Intel LibRealSense library:

cd ${HOME}/librealsense
mkdir build  && cd build
cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DENABLE_CCACHE=ON \
    -DBUILD_EXAMPLES=ON \
    -DBUILD_GRAPHICAL_EXAMPLES=ON \
    -DBUILD_PYTHON_BINDINGS=ON \
    -DFORCE_RSUSB_BACKEND=ON
make -j4

Install library:

sudo make install

Modify the path by adding the following line to the .bashrc file:

export PYTHONPATH=$PYTHONPATH:/usr/local/lib

source ~/.bashrc

Install OpenGL

sudo apt-get install python-opengl
sudo -H pip3 install pyopengl
sudo -H pip3 install pyopengl_accelerate==3.1.3rc1

Change Pi settings (enable OpenGL):

sudo raspi-config

Menu 7 Advanced Options > A8 GL Driver > G2 GL (Fake KMS).

Reset the the Raspberry Pi SWAP

Remember to go back and reset the swap size:

sudo sed -i 's/CONF_SWAPSIZE=2048/CONF_SWAPSIZE=100/g' /etc/dphys-swapfile
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start

We enabled a large swap only to compile LibRealSense. It is not prudent to keep a large swap size for a long time. Increasing swap size is a great way to burn out your SD card. Flash-based storage have limited number of writes you can perform until the card is essentially unable to keep the recorded data.

Test LibRealSense

Connect to the Raspberry Pi and run the built-in viewer from a terminal window:

realsense-viewer

realsense-viewer

References

[1] Raspberry Pi 4 and Intel RealSense D435 by Acrobotic Raspi Demos.

[2] Shane Pfaffly. How to change Raspberry Pi's Swapfile Size on Raspbian. BitPi.co . February 11, 2015.