How to setup the intel RealSense software and pyrealsense2 library in Ubuntu on a raspberryi pi 5

Install dependencies

  1. Make Ubuntu up-to-date including the latest stable kernel:

Shell

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
  1. Install the core packages required to build librealsense binaries and the affected kernel modules:

in Shell

sudo apt-get install libssl-dev libusb-1.0-0-dev libudev-dev pkg-config libgtk-3-dev
  1. Install build tools

in Shell

sudo apt-get install git wget cmake build-essential
  1. Prepare Linux Backend and the Dev. Environment
    Unplug any connected Intel RealSense camera and run:

in Shell

sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at

Install librealsense2

  1. Clone/Download the latest stable version of librealsense2 in one of the following ways:
  • Clone the librealsense2 repo

Shell

git clone GitHub - IntelRealSense/librealsense: Intel® RealSense™ SDK

  1. Download and unzip the latest stable librealsense2 version from master branch
    IntelRealSense.zip
  • Run Intel Realsense permissions script from librealsense2 root directory:

in Shell

cd librealsense

./scripts/setup_udev_rules.sh

Notice: You can always remove permissions by running: ./scripts/setup_udev_rules.sh --uninstall

  1. Build and apply patched kernel modules for:
  • Ubuntu 20/22 (focal/jammy) with LTS kernel 5.13, 5.15
./scripts/patch-realsense-ubuntu-lts-hwe.sh
  • Ubuntu 18/20 with LTS kernel (< 5.13)
./scripts/patch-realsense-ubuntu-lts.sh

Building librealsense2 SDK

  • Navigate to librealsense2 root directory and run:

in Shell

mkdir build && cd build
  • Run cmake configure step, here are some cmake configure examples:
    The default build is set to produce the core shared object and unit-tests binaries in Debug mode.
    Use -DCMAKE_BUILD_TYPE=Release to build with optimizations.

in Shell

cmake ../

Builds librealsense2 along with the demos and tutorials:

in Shell

cmake ../ -DBUILD_EXAMPLES=true

For systems without OpenGL or X11 build only textual examples:

Shell

cmake …/ -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=false

  • Recompile and install librealsense2 binaries:

in Shell

sudo make uninstall && make clean && make && sudo make install

install pyrealsense2

in shell

cmake ../ -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=/usr/bin/python3
make -j4
sudo make install

In

cd librealsense/build/Release

find the librealsense2.so and pyrealsense2.cpython-312-aarch64-linux-gnu.so files.

Copy these files using:

cp -L librealsense2.so {destination} 

and

cp -L pyrealsense2.cpython-312-aarch64-linux-gnu.so {destination}

to your project folder.

You now have Pyrealsense2 installed on your Ubuntu

thank you it works for me