View my account

"RuntimeError: Frame didn't arrive within 5000" When Reading Color Frames from Realsense D435

Comments

8 comments

  • MartyG

    Hi Sogol  Does the same problem occur if you test the RealSense SDK's Python example program opencv_viewer_example.py that uses both depth and color streams, please?

    https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/opencv_viewer_example.py

     

     

    0
    Comment actions Permalink
  • Sogol

    Hi again @MartyG,
    Hope you are doing well.
    I can confirm that there is no problem when I use the example code "OpenCv viewer". However, as soon as I use a similar approach in a new script, I will have the mentioned Runtime error traced back to " frames = pipeline.wait_for_frames()".

    Within the test code, I am using the same approach as the example script. A while loop with try/catch blocks to get frames while the streaming from camera is alive. I do not have any time constraints. So, the stream should happen as long as I have not killed the program myself. However, based on the print logs the streaming session is killed after about 7 secs. with the RunTimeEroor Frame didn't arrive within 5000.
    So, there were about 2 sec. of actual streaming with arriving frames. Furthermore, the number of arrived frames does not match the frame rate --- set as 30 fps within the method "enable_stream".
    I have added the terminal prints for your further information to the following.

    0
    Comment actions Permalink
  • Sogol
    Configuring available RealSense device(s) for both depth and color images.
    Start streaming data frames from the available device with name: Intel RealSense D435, product id 0B07 and S/N 233622079158 @ time 1686868638.330281
    Stop streaming data frames from the available device with name: Intel RealSense D435, product id 0B07 and S/N 233622079158 @ time 1686868645.7039008
    This is the number of received depth frames 31 
    and the number of received color frames: 31
    Traceback (most recent call last):
      File "intel_camera_test.py", line 65, in <module>
        frames = pipeline.wait_for_frames()
    RuntimeError: Frame didn't arrive within 5000
    0
    Comment actions Permalink
  • MartyG

    If opencv_viewer_example.py works normally then this indicates that the camera and the USB connection are fine and the issue is with some aspect of your intel_camera_test.py script.

     

    What happens if you change wait_for_frames() to try_wait_for_frames()  so that when an exception occurs, the program should try to keep running instead of exiting with an error.

     

    0
    Comment actions Permalink
  • Sogol

    Hi again MartyG,
    Hope all is well with you.
    I have used your suggestion and increased the wait time within the camera. Now, the code executes without any run time error as the exception is handled. However, the connection still drops after almost 2 secs. No frame, either depth or color, is received after the 2 sec. period. 

    0
    Comment actions Permalink
  • MartyG

    What happens if you place a pipeline stop instruction at the end of the script?

     

    finally:

    pipeline.stop()
    0
    Comment actions Permalink
  • Sogol

    Hi again MartyG,
    The code already has the pipeline.stop() after the streaming period is finished. This is the code block.

    While time() - start_time_stream <= 10:
    frames = pipeline.try_wait_for_frames()
    if frames.get_depth_frame():
    try:
    if not frames.get_color_frame():
    print("Error. Received frame at time {} is corrupted. Depth is received with no color data".
    format(time()))
    raise IndexError
    depth_list.append(frames.get_depth_frame())
    color_list.append(frames.get_color_frame())
    except IndexError:
    print("Dropping the corrupted frame at time {}".format(time()))

    stop_stream_time = time()
    pipeline.stop()

     

    0
    Comment actions Permalink
  • MartyG

    I would recommend avoiding using the append instruction if possible, as in a RealSense Python script it often causes the program to stop receiving frames after only the first 15 frames.  If you do need to use append then a workaround is to store frames in memory with the Keep() instruction.  The link below provides information about the limitation of using append and the Keep() workaround.

    https://github.com/IntelRealSense/librealsense/issues/6164#issuecomment-607714808

    0
    Comment actions Permalink

Please sign in to leave a comment.