Skip to content
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

Convert raw depth data to rs.object #10770

Closed
pixml27 opened this issue Aug 12, 2022 · 6 comments
Closed

Convert raw depth data to rs.object #10770

pixml27 opened this issue Aug 12, 2022 · 6 comments

Comments

@pixml27
Copy link

pixml27 commented Aug 12, 2022


Required Info
Camera Model {D400 }
Firmware Version ....
Operating System & Version Linux (Ubuntu 20.04)
Kernel Version (Linux Only) (5.4.8)
Platform PC
SDK Version ...
Language {python }
Segment { others }

Issue Description

Hi guys!
We are trying to repeat this example
However, we don't have access to live cameras, all we have is stored infrared images, depth images and raw depth data.

Our only problem is we can't apply filters to the depth image because we have raw data and not an rs2::frame object.

So, is there a way to convert the numpy array loaded from the xxx_Depth.raw file into the rs.stream.depth object that is being used here?

image

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Aug 12, 2022

Hi @pixml27 If your goal is to convert a numpy array to rs2::frame format in Python, this has previously been explored by RealSense users but remains an unsolved problem unfortunately as far as I am aware, as described in #2551 and #5784

Whilst the RealSense SDK's software device interface can be used, it works best with C++ and has been shown to have difficulties with using it in Python scripts.

cv::mat to rs2::frame is feasible, as advised by a RealSense team member at #2634 (though the scripting is C++).

@pixml27
Copy link
Author

pixml27 commented Aug 13, 2022

@MartyG-RealSense thank you for you answer!
Ok, I will not use post-processing - I have questions further
What are the values in raw depth data measured in, cause i'm sure it is not meters!
image

I need to use two functions: first and second
So i want to implement depth_frame.as_depth_frame().get_distance by myself - do you have any advices how can i do it?)

@MartyG-RealSense
Copy link
Collaborator

Raw 16-bit 'pixel depth' values (uint16_t) like those in the above image can be multiplied by the depth unit scale of the camera to convert them to the real-world distance in meters. For all 400 Series models except the D405 the default depth unit scale is 0.001 and does not changed unless altered deliberately by the program or by user input.

For example, for a raw depth value of 3735, multiplying it by 0.001 gives a real-world distance of 3.375 meters.

If the get_distance() instruction is used though then you do not have to multiply by the depth scale as the instruction does it for you and provides the result in meters.

#9939 should be a helpful reference for Python scripting for get_distance and for information about the difference between uint16t * depth scale and obtaining depth in meters with get_distance()

@pixml27
Copy link
Author

pixml27 commented Aug 14, 2022

@MartyG-RealSense Thanks for the tips and links - they helped a lot!

@MartyG-RealSense
Copy link
Collaborator

Hi @pixml27 Do you require further assistance with this case, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants