Items with no label
3338 討論

Looping through all pixels for depth is too slow

SMath17
初學者
1,284 檢視

Hi,

I am trying to save all the depth values in a frame. But if I loop through all pixels, it's too slow for 640 x 480.

I want to save all the depth values in a frame to a text file, but by the time it's done with first frame, we we already missed many many frames. How can I get around this? thanks

private void print_DepthFrameData(DepthFrame depth) { int skipPixels = 1; for (int i = 0; i < depth.Width; i += skipPixels) { for (int j = 0; j < depth.Height; j += skipPixels) { string frameNumber = depth.Number.ToString(); int pixelPointX = i; int pixelPointY = j; float distanceMM = depth.GetDistance(pixelPointX, pixelPointY); Console.WriteLine(frameNumber + " - " + "(" + pixelPointX + "," + pixelPointY + "): " + distanceMM); } } }

 

 

Capture.PNG

0 積分
1 解決方案
MartyG
榮譽貢獻者 III
881 檢視

An SDK program called 'rs-depth' in the C language (not C++ or C#) prints a text-based representation of the depth image, This may give you some insights about approaches for optimizing your own script if you prefer to stick with that method. The script breaks the image into 10x5 pixel regions and approximates the coverage of pixels within one meter.

 

https://github.com/IntelRealSense/librealsense/tree/master/examples/C/depth

 

The most efficient way to record data is to save it into a 'bag' file. Other types of file saving, such as text or 'ply' point cloud data, may be considerably slower to record in real-time. The long discussion linked to below on the subject of file saving may be useful to you.

 

https://github.com/IntelRealSense/librealsense/issues/1485

 

It includes a script provided by Dorodnic the RealSense SDK Manager to save raw depth data into a file as bytes.

 

https://github.com/IntelRealSense/librealsense/issues/1485#issuecomment-379703868

 

A bag file recording can also be converted outside of a program to a text file format called .csv that is suited to spreadsheets and databases. This can be done with a tool in the RealSense SDK called Convert.

 

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

在原始文章中檢視解決方案

3 回應
MartyG
榮譽貢獻者 III
882 檢視

An SDK program called 'rs-depth' in the C language (not C++ or C#) prints a text-based representation of the depth image, This may give you some insights about approaches for optimizing your own script if you prefer to stick with that method. The script breaks the image into 10x5 pixel regions and approximates the coverage of pixels within one meter.

 

https://github.com/IntelRealSense/librealsense/tree/master/examples/C/depth

 

The most efficient way to record data is to save it into a 'bag' file. Other types of file saving, such as text or 'ply' point cloud data, may be considerably slower to record in real-time. The long discussion linked to below on the subject of file saving may be useful to you.

 

https://github.com/IntelRealSense/librealsense/issues/1485

 

It includes a script provided by Dorodnic the RealSense SDK Manager to save raw depth data into a file as bytes.

 

https://github.com/IntelRealSense/librealsense/issues/1485#issuecomment-379703868

 

A bag file recording can also be converted outside of a program to a text file format called .csv that is suited to spreadsheets and databases. This can be done with a tool in the RealSense SDK called Convert.

 

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

SMath17
初學者
881 檢視

First, thank you for all your help! I have seen you are very active in responding to everyone's posts.

 

Thanks for the info, I tried to create a .bag file and it was created successfully. But the file is too huge (for 1 min).

Is it possible to reduce the frequency of frames in .bag file? I only care about few fps, not many. Can this be configured?

Or is it possible to only record depth values in .bag file, not everything.

 

Thanks!

MartyG
榮譽貢獻者 III
881 檢視

Thanks for your kind words!

 

I responded to your post on the GitHub.

 

https://github.com/IntelRealSense/librealsense/issues/3537?language=en_US#issuecomment-474578076

回覆