Pyrealsense2 RuntimeError:
-
Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):
- Consider checking out SDK examples.
- Have you looked in our documentations?
- Is you question a frequently asked one?
- Try searching our GitHub Issues (open and closed) for a similar issue.
-
All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)
| Required Info | |
|---|---|
| Camera Model | D435i |
| Firmware Version | not sure (default) |
| Operating System & Version | Win 10 |
| Platform | PC |
| IDE | Pycharm |
| SDK Version | 2.33. |
| Language | python |
| Segment | object detection |
Issue Description
<Describe your issue / question / feature request / etc..> Hi everyone! I have install pyrealsense2 using pip. But I try to use Pycharm to read the data captured by Intel D435i. I always get error as follows:
Traceback (most recent call last):
File "D:/PycharmProject/IntelCamera/test.py", line 12, in
The python codes is shown as follows;
import pyrealsense2 as rs import numpy as np import cv2
Configure depth and color streams
pipeline = rs.pipeline() config = rs.config() config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
Start streaming
pipeline.start(config)
try: while True:
# Wait for a coherent pair of frames: depth and color
frames = pipeline.wait_for_frames()
depth_frame = frames.get_depth_frame()
color_frame = frames.get_color_frame()
if not depth_frame or not color_frame:
continue
# Convert images to numpy arrays
depth_image = np.asanyarray(depth_frame.get_data())
color_image = np.asanyarray(color_frame.get_data())
# Apply colormap on depth image (image must be converted to 8-bit per pixel first)
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)
# Stack both images horizontally
images = np.hstack((color_image, depth_colormap))
# Show images
cv2.namedWindow('RealSense', cv2.WINDOW_AUTOSIZE)
cv2.imshow('RealSense', images)
key = cv2.waitKey(1)
# Press esc or 'q' to close the image window
if key & 0xFF == ord('q') or key == 27:
cv2.destroyAllWindows()
break
finally:
# Stop streaming
pipeline.stop()
I am new to this field. So I don't know how to solve this problem. Thanks for your assistance.
"Failed to resolve the request" may indicate that the SDK has been asked to perform an action that is does not understand. An example of such a request may be defining a resolution or stream format that is not supported or has a spelling mistake. Your stream definition statements look correct though.
Could you try changing pipeline.start(config) to this please:
profile = pipeline.start(config)
"Failed to resolve the request" may indicate that the SDK has been asked to perform an action that is does not understand. An example of such a request may be defining a resolution or stream format that is not supported or has a spelling mistake. Your stream definition statements look correct though.
Could you try changing pipeline.start(config) to this please:
profile = pipeline.start(config)
Dear Sir or Madam, I have try your code. But it returns the same error. What should I try? Thanks a lot.
I researched the issue further. There was a past case of a Python Pycharm user who experienced the same error. They were advised that the defined stream configuration may have been valid on a USB3 connection but not supported on USB2.
https://github.com/IntelRealSense/librealsense/issues/1656#issuecomment-389136061
Is your camera in a USB 3 port please, and if so, is it detected as USB 3?
I have double checked. I can confirm that the USB is 3 and the Intel Viewer displays as USB 3.2. But it returns the result. Thanks.
The trace log suggests that the problem occurs at pipeline.start(config) when the pipeline started but it was not able to process the request to activate a depth stream with resolution 640x480 and 30 FPS. There would not be a problem with the chosen stream format (Z16).
I am currently conducting further research. In the meantime, could you confirm that you are able to test the camera as working in SDK programs such as the RealSense Viewer, please?
I wonder if you could try a simpler test script that uses config and see if the error still occurs.
import pyrealsense2 as rs pipeline = rs.pipeline() config = rs.config() config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) pipeline.start(config)
Sorry for the delay. I have tested your simple codes. It returns the same error"Failed to resolve the request"
And I have checked Intel Viewer. The resolutions of stereo module and RGB camera are 848480, 1280720 respectively. I don't know do these resolution have certain effects?
Higher resolutions may make streaming lag on some computers, but all supported resolutions should be recognised if the camera is on a USB 3 connection.
The absolute most basic state that the test script can be reduced to is a one-line script to test whether the pyrealsense2 module can be detected:
import pyrealsense2 as rs
If you still get an error from that then it may indicate a more fundamental prob;lem with the pyrealsense2 installation than just a stream configuration issue.
There is no error when only run "import pyrealsense2 as rs". I think that I have successfully installed pyrealsense using pip. But when run the previous codes. It causes same error. Thanks.
Let's test the camera with a couple more test scripts to confirm that pyrealsense2 is streaming properly.
First there is this simple example from the PyPi pip site:
import pyrealsense2 as rs pipe = rs.pipeline() profile = pipe.start() try: for i in range(0, 100): frames = pipe.wait_for_frames() for f in frames: print(f.profile) finally: pipe.stop()
And here is a more complex beginner script called tutorial_1_depth that renders the depth stream on-screen in the form of ASCII text-character art.
https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/python-tutorial-1-depth.py
Dear Sir or Madam, I have tested the tutorial_1_depth script. But it still returns the same error‘Failed to resolve the request: Format: Z16, width: 848, height: 480
Into: Formats: Z16‘ Does this means that the pyrealsense2 is streaming inproperly? Some scripts have been tested and the results/error are the same. I have no idea about that. Thnaks.
The same error has occurred for others, even when only streaming infrared:
https://github.com/IntelRealSense/librealsense/issues/3885
Have you tried updating the firmware driver of your D435i please?
Dear MartyG, I hvae checked the specification which is shown as follows:
- Name: Intel RealSense D435I, serial number: 919122070934, update serial number: 908323050036, firmware version: 05.12.05.00, USB type: 3.2 I think the firmware is up to date. Thanks.
Thanks. Yes, your firmware is up to date.
Did you find anything helpful in https://github.com/IntelRealSense/librealsense/issues/3885
I think I have no such issues which are presented in the link. I have no progress on this error. Thanks.
Since the simple example scripts did not work for you, the problem is unlikely to be caused by your custom config stream configuration.
Researching further, I came across a past case I had handled where the 'could not resolve request' error on Pyrealsense2 disappeared after the RealSense user used the Dynamic Calibrator software of the SDK to recalibrate the camera.
The Dynamic Calibrator tool can be downloaded from here:
https://downloadcenter.intel.com/download/29618/Intel-RealSense-D400-Series-Dynamic-Calibration-Tool
Dear MartyG, I have tried Dynamic Calibrator tool. But it returens 'Failed to start calibration' and consequently the python script fails again.Thanks.
"Failed to start calibration" can be a symptom of being on a USB 2 connection. This is because the Dynamic Calibrator tool needs the camera to be on a USB 3 connection.
A number of RealSense users have experienced problems with a failed calibration on the Dynamic Calibrator though even when plugged into USB 3.
https://github.com/IntelRealSense/librealsense/issues/3990
A RealSense team member states in the above link that the Dynamic Calibrator also currently has problems with running on Ubuntu PCs that have the '5.3' kernel version. You listed in your information at the start of the case that you were using Windows. Can you confirm please that you ran the Dynamic Calibrator program on Windows?
I can confirm that I ran Dynamic Calibrator on Window 10 and the USB is 3. But it fails. Thanks.
Assuming that you are using Windows 10 and not Windows 7 (as your provided information at the top of the case says Win 10):
One thing we have not considered is if the problem might be with Pycharm, and if using a different Python compiler might make a difference.