1

I've been trying to setup librealsense on my Raspberry Pi4 using Balena. My docker file looks like:

FROM balenalib/raspberrypi3-ubuntu:xenial-build
RUN sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y
RUN sudo apt-get install -y python3 \
    python3-dev \
    python3-pip \
    python3-setuptools 

RUN sudo apt-get install -y git libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev cmake libglfw3-dev build-essential 
RUN git clone https://github.com/IntelRealSense/librealsense.git
RUN cd librealsense/ && ./scripts/setup_udev_rules.sh
RUN mkdir build &&\
    cd build &&\
    cmake /librealsense/ -DBUILD_PYTHON_BINDINGS=true -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=false -DCMAKE_BUILD_TYPE=Release &&\
    make all -j4 &&\
    sudo make all 

COPY librealsense/build/ /usr/src/app/

#switch on systemd init system in container
ENV INITSYSTEM on

WORKDIR /usr/src/app
COPY ./app/ /usr/src/app/


#Run our binary on container startup
CMD ["python3", "/usr/src/app/test_server.py"]

And my test_server.py looks like:

import sys, os
print("TEST")
rootdir = '/usr/src/app'
for f in os.listdir(rootdir):
    print(f)
print(sys.version)
try:
    user_paths = os.environ['PYTHONPATH'].split(os.pathsep)
except KeyError:
    user_paths = []
print(user_paths)
print(sys.path)
sys.path.append('/usr/src/app/')
import pyrealsense2 as rs

I am unable to import pyrealsense or copy over built .so files to put into my python application folder. I get 'librealsense/build/python does not exist' errors when I create the docker image. What am I missing in my librealsense install?

ddiddi
  • 11
  • 1

1 Answers1

0

I think your problem is with

COPY librealsense/build/ /usr/src/app/

This would attempt a copy of 'librealsense/build' from your build context (aka host machine). You need to use 'RUN' together with 'cp', eg

RUN cp librealsense/build/ /usr/src/app/

or in a single RUN command:

RUN mkdir build &&\
    cd build &&\
    cmake /librealsense/ -DBUILD_PYTHON_BINDINGS=true -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=false -DCMAKE_BUILD_TYPE=Release &&\
    make all -j4 &&\
    sudo make all  &&\
    cp librealsense/build/ /usr/src/app/
Hardy
  • 18,659
  • 3
  • 49
  • 65