View my account

Segmentation fault when trying to run a python script on a D455 realsense camera on a raspberry pi 4

Comments

16 comments

  • MartyG

    Hi Damian Lagunes Spolo Does the script still segfault if you run a test script with only the first line in it?

    import pyrealsense2 as rs
    0
    Comment actions Permalink
  • Damian Lagunes Spolo

    Hi Marty, 

    No, I dont get any errors if I do that.

    0
    Comment actions Permalink
  • Damian Lagunes Spolo

    In last instruction of this script is where I get the segmentation fault:


    import pyrealsense2 as rs


    # Create a context object. This object owns the handles to all connected realsense devices
    pipeline = rs.pipeline()

    # Configure streams
    config = rs.config()
    config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)

    # Start streaming
    pipeline.start(config)

    0
    Comment actions Permalink
  • MartyG

    Your script looks fine.  There should not be any problem with that stream configuration.

     

    We can eliminate the stream configuration as a cause if 'config' is temporarily removed from the brackets of the pipe start instruction, as the program will then ignore the config line when launched.  If a segfault still occurs then it is the pipe start that is causing it.

    pipeline.start()
    0
    Comment actions Permalink
  • Damian Lagunes Spolo

    I removed the stream config as you said and still having the issue. It seems that the problem is the pipeline start.

    0
    Comment actions Permalink
  • MartyG

    Have you got any other RealSense programs running already at the same time, such as the RealSense Viewer tool, when you run your Python script, please?

     

    Which model of Raspberry Pi are you using?  If it is one with a small memory capacity such as 1 GB then you could try increasing the size of the virtual-memory swapfile to 4096 instead of 2048.

    https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_raspbian.md#add-swap

     

    Does the program still segfault if you use an amended pyrealsese2 import instruction?

    import pyrealsense2.pyrealsense2 as rs
    0
    Comment actions Permalink
  • Damian Lagunes Spolo

    I am using a raspberry pi 4 model B with 8 Gb ram and have 2 Gb in swap memory. I tried to import the pyrealsense as you said and did not work.

    0
    Comment actions Permalink
  • MartyG

    Does the same segfault occur with the Python wrapper's test script at the link below?

    https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/readme.md#streaming-using-rspipeline

    0
    Comment actions Permalink
  • Damian Lagunes Spolo

    Yes I have the same error.

    0
    Comment actions Permalink
  • MartyG

    Are you using Python 2 or Python 3?

     

     

    0
    Comment actions Permalink
  • Damian Lagunes Spolo

    I am using python 3

    0
    Comment actions Permalink
  • MartyG

    As you are using Raspbian / Raspberry Pi OS, what version of Raspberry Pi OS are you using?  The Buster version of the OS works with RealSense but the Bullseye version that came after it had problems when used with RealSense.

    0
    Comment actions Permalink
  • Stefan Hickox

    Hi, I am experiencing this exact same issue as described.

    I am running a fresh installed, 64 bit debian (Bullseye) on a raspberry pi 4 Module. I have the Pi connected to a D455 camera. I have followed the instructions instructions from this link: https://github.com/datasith/Ai_Demos_RPi/wiki/Raspberry-Pi-4-and-Intel-RealSense-D435. These instructions have worked previously on Debian(Buster) version of the OS back in 2021 with no issue.

    Installations appears to have worked fine for the SDK install, however whenever I run the demo python scrypt, from within the compiler or through command line, I get a segmentation fault. This appears to always occur when python reaches the "pipeline.start(config)" command. It also occurs if I do not change any config settings and simply try pipeline.start().

    During installation, the only part of the code that failed to run was the  during the "enable OpenGL" instructions:

    $ sudo apt-get install python-opengl
    and
    "7.Advanced Options" - "A7 GL Driver" - "G2 GL (Fake KMS)"

    Python-openg1 was unable to be found on the Bullseye OS, but  i could still install pyopengl/pyopengel_accelerate via pip. Also advanced option "A7 GL Driver" is not visable on the raspi-config menu. Looking into this, it appeares the debian (Bullseye) version might natively run with Full KMS (OpenGL) without the need to install: https://forums.raspberrypi.com/viewtopic.php?t=336262. 
    Any suggestions on how this could be solved would be appreciated.

    0
    Comment actions Permalink
  • MartyG

    Hi Stefan Hickox  The only known fix for Bullseye is to compile Buster and then copy some unnamed 'binaries' across from Buster to Bullseye.

    https://github.com/IntelRealSense/librealsense/issues/9943#issuecomment-966048785

    0
    Comment actions Permalink
  • Stefan Hickox

    HIi MartyG,

    Unfortunately that gives no indication of what 'binaries' are needed to migrate from Buster to Bullseye. I would not be able to replicate this without more details.

    Is the only available solution to work from a buster image of the OS?

    0
    Comment actions Permalink
  • MartyG

    I have previously researched this solution but there aren't any further details available other than the '2 binaries' mentioned by the solution's provider, unfortunately.  So if the names of the binaries are not known then using Buster instead of Bullseye is likely to be the best course of action.

    0
    Comment actions Permalink

Please sign in to leave a comment.