"RuntimeError: Frame didn't arrive within 5000" When Reading Color Frames from Realsense D435
Hi,
I am using Realsense D435 in a stationary mode and for streaming both depth and color frames. I can read both depth and color frames when using the camera's Intel viewer app. However, when I use the API to access the camera's frame, I will eventually get this error only when trying to read the color frames. I am using Python wrapper and an OSX system for programming. However, I have reproduced the error both on my machine and also a machine with windows OS.
I have narrowed down the issue to raise after I aim to read the frames through the method "frames.get_color_frame()". Enabling color streaming for the camera "config.enable_stream(rs.stream.color)" does not cause the connection loss and the mentioned RuntimeError.
Any suggestions and possible solutions would be appreciated.
Thanks in advance!
-
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?

-
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. -
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 -
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.
-
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. -
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() -
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
Please sign in to leave a comment.
Comments
8 comments