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

How to get CSV snapshots #11090

Closed
singchee opened this issue Nov 11, 2022 · 5 comments
Closed

How to get CSV snapshots #11090

singchee opened this issue Nov 11, 2022 · 5 comments

Comments

@singchee
Copy link

singchee commented Nov 11, 2022

Required Info
Camera Model D415
Firmware Version 2.51.1.4348
Operating System & Version Windows 11

Hi Everyone

I'm really new to using the D415, and have no programming experience so am struggling.

What I'm trying to do

  1. Take still images of people's face and generate a depth map
  2. Have the depth map represented as a CSV file (or equivalent) that can be used for analysis of the facial contours

From reading the posts, it seems this I can do this by

  1. Taking a "snapshot" in the 2D mode of the Realsense viewer (using the stereoscoping stream) - this exports to a .raw file
  2. Use a script to get the depth data from each pixel - as described here: How to get the depth value of a specific coordinate through the stored depth picture. #2200
    however, what I need help understanding is
  • What programming language is needed to extract the depth data for each pixel (e.g. in the link above, what language is used)?
  • How is the depth data represented?
  • how can i get it into a CSV format?

Thank you very much!

Sing

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Nov 11, 2022

Hi @singchee Whilst the RealSense Viewer's "Snapshot" feature does export a .csv file, it only contains camera metadata rather than depth data.

image

If you wish to explore how to export a .csv with programming code then a modification of the RealSense SDK's C++ rs-capture example program at the link below that was created by a RealSense team member that exports data to .csv may be a helpful programming reference.

https://github.com/dorodnic/librealsense/tree/text_sample/examples/capture

https://github.com/dorodnic/librealsense/blob/text_sample/examples/capture/rs-capture.cpp

In regard to how depth data is represented, it is a set of coordinates with a numeric value in meters that represents the distance from the camera of a particular coordinate on the depth image. For example, 50 cm from the camera would be '0.5' meters.


An alternative to using programming would be to record a short bag file using the Viewer's Record button. The pre-made tool rs-convert could then be used to extract the bag's depth frames to .csv.

https://github.com/IntelRealSense/librealsense/tree/master/tools/convert

If you have installed the full RealSense SDK using the Intel.RealSense.SDK-WIN10 installer program from the SDK 'Releases' page at the link below then the pre-built executable version of rs-convert on Windows can be launched in the Windows Command Prompt text interface using the following instructions.

https://github.com/IntelRealSense/librealsense/releases

  1. Go to the SDK's Tools folder by right-clicking on the RealSense Viewer launch shortcut on the Windows desktop and selecting the menu option Open file location.

  2. In the address bar at the top of the Tools folder window, left-click on the end of the address text-box to convert it to the Windows-format address C://Program Files (x86)/Intel RealSense SDK 2.0/Tools

  3. Copy the contents of the address box with CTRL-C and go to the Command Prompt window.

  4. Type cd followed by a space and use CTRL-V to paste the address into the Command Prompt window and press return.
    The directory will change to the Tools folder.

  5. Input an rs-convert bag file extraction command like the ones on the rs-convert tool's instructions web-page. For example, to extract the bag file frames in .csv format with the -v flag:

rs-convert.exe -v test -i 1.bag

If a folder path is not provided for the bag file to tell rs-convert where on the computer the file is located then the bag file should be copied into the same Tools folder where the rs-convert .exe program is located.

@singchee
Copy link
Author

singchee commented Nov 11, 2022

Thanks Marty, yes agree the .CSV with the export function is very limited.

Is there a guide on how to extract depth data from the raw file? The links provided above are extracting data from the feed.

Alternatively would you know how we can get depth data from a saved .ply file?

Thanks again!

@MartyG-RealSense
Copy link
Collaborator

There is a recent discussion at the link below regarding reading depth data from a .raw file.

https://support.intelrealsense.com/hc/en-us/community/posts/11024587584915-How-to-get-the-depth-information-from-raw-file-python-

In regard to RealSense .ply point cloud files, you can import them into other software tools such as MeshLab or into specialized pointcloud libraries such as PCL in order to do further work with them , but it is not practical to load them back into the RealSense SDK directly.

https://www.andreasjakl.com/capturing-3d-point-cloud-intel-realsense-converting-mesh-meshlab/

If you wanted to capture a single-frame snapshot that preserves the depth data perfectly in a format that can be directly read by an SDK script as though it were live camera data then you could use a script with the save_single_frameset() instruction to save a single depth frame to a bag format file. The link below has a complete Python script that demonstrates this function.

https://github.com/soarwing52/RealsensePython/blob/master/separate%20functions/single_frameset.py

@MartyG-RealSense
Copy link
Collaborator

Hi @singchee 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