-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disparity Map and Valid Depth Mask creation #8572
Comments
Hi @Novruz97 Does the output of the Python / OpenCV disparity map generation tutorial in this link produce an output from your D435i that resembles what you are aiming for, as shown in the image below from the tutorial? https://docs.opencv.org/3.4/dd/d53/tutorial_py_depthmap.html |
Having considered your case again, it seems as though you are trying to generate the disparity map inside of the librealsense SDK instead of doing it outside of the SDK. There are not many scripting references for generating a disparity map, as your own research has likely shown. I was able to find a C++ script by a RealSense user who took the approach of accessing the disparity mode of the camera through the camera's Advanced Mode. Though you are using Python, that user's approach may provide some useful insights. https://support.intelrealsense.com/hc/en-us/community/posts/360051896473/comments/360014626993 |
Hello @MartyG-RealSense, thank you for replying! try:
finally: Several things to note:
the disparity should be in pixels (even in realsense documentation). But I don't think either types (int16 nor float32) gives correct result. Below is disparity computation without casting to float and dividing by 16: I am still working on the second reply link you gave me, getting disparity with advanced mode, though Im not good at c++. If you could give some advice on the upper questions, will much appreciate! |
The subject of programming disparity maps is outside of my knowledge, unfortunately so I do not have advice that I can offer about that. In regard to numDisparities though, Intel have a Python example for demonstrating stereo depth that makes use of it. This may provide you with some useful insights. The full source code of this example is below.
|
Hi @Novruz97 Do you require further assistance with this case, please? Thanks! |
Hello @MartyG-RealSense , sorry for late reply!
` I tried to normalize the data to shape to np.uint8, but it throws an integer type error. |
I researched your question about normalization carefully. Whilst the RealSense SDK provides the ability to switch between depth and disparity modes with depth_to_disparity and disparity_to_depth, this does not seem possible with this particular script. If your goal is to normalize a numpy array, the reference in the link below did suggest though that dividing the array by its norm would normalize it. https://www.kite.com/python/answers/how-to-normalize-an-array-in-numpy-in-python |
@MartyG-RealSense Thank you for your help in this! |
Great news @Novruz97 - thanks for the update! |
Issue Description
Hello dear Realsense team,
Im learning Opencv with Python3. The author of the book, uses OpenCV's Openni2 functions:
CAP_OPENNI_DISPARITY_MAP
andCAP_OPENNI_VALID_DEPTH_MASK
to get the results:I have learned from documentation how to transform depth to disparity. However, when I transform it, I get following result (I changed dtype=np.uint8) :
From the issues #1778, #7431 , it seems that to get correct disparity I need to cast the array to float, but I get this:
Data is as follows:
So I clearly don't understand what's the problem. If disparity cast to float, it looks like valid depth mask image from book. If it is uint8, wavy image.
Kindly, waiting for your reply!
The text was updated successfully, but these errors were encountered: