librealsense: pyrealsense2: RuntimeError: Frame didn't arrive within 5000
Required Info | |
---|---|
Camera Model | D435 |
Firmware Version | 05.12.06.00 |
Operating System & Version | Win 10 |
Platform | PC |
SDK Version | 2.36.0.2034 |
Language | python3.7.5 64bit |
Issue Description
I installed the RealSense SDK for the first time today and want to develop in python. Using RealSenseViewer works without problems.
But whatever I do in python, I run into
RuntimeError: Frame didn't arrive within 5000
The code I use is:
import pyrealsense2 as rs
rs.log_to_file(rs.log_severity.debug, file_path='./log.txt')
device = rs.context().devices[0]
serial_number = device.get_info(rs.camera_info.serial_number)
print(serial_number)
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
pipeline.start(config)
frames = pipeline.wait_for_frames()
depth = frames.get_depth_frame()
It reads the serial number correctly and I can find further information about the camera debugging. But reading frames won’t work.
I installed the SDK with the installer. Python is running in a virtual environment. I used pip to install pyrealsense2.
To log of above code is:
06/08 16:41:22,027 DEBUG [16436] (win-helpers.cpp:87) res=pSensorManager->GetSensorsByCategory(SENSOR_CATEGORY_ALL, &pSensorCollection) returned: HResult 0x80070490: "Element nicht gefunden."
06/08 16:41:22,045 DEBUG [16436] (win-helpers.cpp:87) res=pSensorManager->GetSensorsByCategory(SENSOR_CATEGORY_ALL, &pSensorCollection) returned: HResult 0x80070490: "Element nicht gefunden."
06/08 16:41:22,061 DEBUG [16436] (ds5-factory.cpp:1109) try_fetch_usb_device(...) failed.
06/08 16:41:22,061 INFO [16436] (context.cpp:365) Found 1 RealSense devices (mask 254)
06/08 16:41:22,190 DEBUG [16436] (win-helpers.cpp:87) res=pSensorManager>GetSensorsByCategory(SENSOR_CATEGORY_ALL, &pSensorCollection) returned: HResult 0x80070490: "Element nicht gefunden."
06/08 16:41:22,206 DEBUG [16436] (ds5-factory.cpp:1109) try_fetch_usb_device(...) failed.
06/08 16:41:22,206 INFO [16436] (context.cpp:365) Found 1 RealSense devices (mask 254)
06/08 16:41:22,207 DEBUG [16436] (win-helpers.cpp:87) res=pSensorManager->GetSensorsByCategory(SENSOR_CATEGORY_ALL, &pSensorCollection) returned: HResult 0x80070490: "Element nicht gefunden."
06/08 16:41:22,225 DEBUG [16436] (ds5-factory.cpp:1109) try_fetch_usb_device(...) failed.
06/08 16:41:22,225 INFO [16436] (context.cpp:365) Found 2 RealSense devices (mask 255)
06/08 16:41:22,368 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,368 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,369 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,385 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,385 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,385 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,385 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,396 INFO [16436] (sensor.cpp:1341) Request: Z16 Depth,
Resolved to: Z16 Depth,
06/08 16:41:22,413 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,414 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,414 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:22,418 DEBUG [16436] (global_timestamp_reader.cpp:141) time_diff_keeper::start: _users_count = 1
06/08 16:41:27,432 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:27,432 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:27,433 DEBUG [16436] (win-helpers.cpp:87) _reader->GetNativeMediaType(sIndex, k, &pMediaType.p) returned: HResult 0xc00d36b3: "Die angegebene Datenstromnummer war ungültig."
06/08 16:41:27,434 DEBUG [16436] (global_timestamp_reader.cpp:152) time_diff_keeper::stop: _users_count = 0
06/08 16:41:27,434 DEBUG [16436] (global_timestamp_reader.cpp:155) time_diff_keeper::stop: stop object.
06/08 16:41:27,434 DEBUG [6448] (global_timestamp_reader.cpp:226) Notification: time_diff_keeper polling loop is being shut-down
Happy for any help. Thank you.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18
Hi @MartyG-RealSense, thank you for your prompt reply.
If I understand well,
pipeline.wait_for_frames()
has 5000 as a default value for the optional parameter timeout_ms. https://intelrealsense.github.io/librealsense/python_docs/_generated/pyrealsense2.pipeline.html#pyrealsense2.pipeline.wait_for_framesBut, yes, I tried with and without 5000, with 50’000 and also tried the function
try_wait_for_frames()
. While in debug mode it works fine, when I run the script (in PyCharm or in a Jupyter lab) I never get a frame. Thanks.Update: I (sort of) solved my problem. I don’t have a clear explanation and I don’t how to make it work on Jupyter Lab (yet) but it seems that it is a configuration problem. For people using PyCharm encountering the same problem, in the menu, select "Run"->“Edit Configurations…”. In the section “Execution” be sure to have the option “Run with Python Console” checked. That’s it. Someone more knowledgeable probably will know why it works in debug mode without this option enabled. Thank you for the support and sorry for the noise.
Ok, final update from my side. What caused problems to run the code on Jupyter was… Kaspersky endpoint security 😣. I had just to turn it off and everything worked fine. Thanks again.