Cannot Read Depth Data from a Bag File Recorded from a D415
I recorded a bag from my D415 using RealSense Viewer...
Now i tried to read depth data using get_distance() method ... and i just get 0.00
I can read depth data from other bag files (example one provided by Intel ...) using the same code...
So, everything leads me to think that it's something wrong with my bag... but i simply cannot figure what is wrong... i can playback the bag file in RealSense Viewer and i can see the depth frames with colorizer ... so, depth info seems to be there... right ?
Any hints or ideas ?
-
Hi David Other RealSense users have experienced zero depth when accessing bag data with get_distance(). A RealSense user shared their solution for the Python programming language in the link below, and others verified that it worked for them too.
https://github.com/IntelRealSense/librealsense/issues/5878#issuecomment-614631975
Is a Python-based solution suitable for you please or do you require a solution in another programming language such as C+ or C# please?
-
Yes, Python is exactly what 'm using here...
I spent some days trying to figure how to address this issue... This post mentioned refers to way to load configs for each bag file ... (as i can understand...). But that's not my case. I have just one bag file...
And i cannot read depth from it's pixels using get_distance() as i said previously.
However, if i try to use get_data() from the depth frame i can read a data ... will return a long number for me ...
However, since get_device().first_depth_sensor().get_depth_scale() generates a runtime error (Could not fins requested sensor type!) i cannot process the depth data properly ... thus cannot get the distance in meters from any point...
Thank you
-
As the distance in meters is the large 16-bit value multiplied by the camera depth scale, if you can get the 16-bit depth value then you could just multiply the 16-bit value by a fixed value of 0.001 (the default depth unit scale) instead of accessing get_depth_scale.
The 16-bit value ranges from 0 to 65535. So for example, 65535 X 0.001 = 65.535 meters.
-
Thanks MartyX Grover
So, what's this method (get_depth_scale) for ?
Also a natural question: What's the difference between using get_distance() and just getting the depth value using get_data() ?
Do these values result in differences ?
Is get_distance() more reliable or accurate somehow ?
Thanks again for helping me ! I really need urgently to move ahead with this in my research.
-
get_depth_scale, as the name suggests, retrieves the current Depth Unit Scale of the camera. Documentation about the Depth Unit Scale can be found in the Change the depth step-size section of Intel's excellent camera tuning guide:
There is a discussion in the link below about the difference between getting the distance in meters with (a) get_distance() and getting it by (b) multiplying the uint16 16-bit depth value by the depth unit scale.
https://github.com/IntelRealSense/librealsense/issues/7264
In that discussion, a RealSense user tested the difference by calculating both and subtracting one result from the other, with the ideal result being zero (no difference). So using one or the other should be fine, depending on your personal preference.
-
Pls accept my apologies for taking so long to post this reply here ... had some personal issues and only now i am resuming this research.
Your suggestion for using the method get_data() of the depth_frame object worked fine !
As you recommended i extracted the 16 bit raw integer and then multiplied by 0.001 and the result has become under the real distance tolerance ...
Thank you, for you recommendations !
Now i'm looking for using the Intrinsics and extrinsics of the camera in order to get the aproximated position of the moving object inside the location in global coordinates.
Again, thank you for your guidance !
-
There is a RealSense tutorial that uses OpenCV and ROS to analyse video provided by a bag file and track the "pose" (position and rotation) of moving objects by their color without having to place tags on the objects.
https://by-the-w3i.github.io/2019/10/06/ColorBlockTracking/
Alternatively, if the ultimate goal of your project is tracking pedestrians in real-time (not from a bag file) and you are able to integrate a commercial solution, the Cubemos Skeleton Tracking SDK for RealSense may be able to provide you with the position data that you need from moving humans.
-
Very interesting material of this one using Kalman filter !
About the cubemos solution... i already studied (but not implemented) it's features ... but what i could learn is that it is oriented to extract the joints (skeleton) ... of course i could subuse it by extracting just the dorso (or head maybe...)... but i could not make sure (by reading its documentation...) that it will give me global position ... i will check again...
Thanks MartyX Grover
Please sign in to leave a comment.
Comments
8 comments