Closed TED-EE closed 4 years ago
Hi @Ted-EE May I clarify please if you mean that you want to export a depth matrix of an image?
If so, a way to do this may be to dump the data to a binary file format such as csv or bin. The subject is discussed in the link below.
https://github.com/IntelRealSense/librealsense/issues/3491
Within that discussion, @RealSenseCustomerSupport offers a script for doing so.
https://github.com/IntelRealSense/librealsense/issues/3491#issuecomment-475389906
@MartyG-RealSense Thanks for your replying. I will look into this link.
@MartyG-RealSense I don't think that link can solve my problem. I would like to make the problem clear. Because I want to do some image processing work on the depth image captured by realsense in Visual Studio C++, it will be better if the depth image is output in matrix form so that I can find the row and the column of the matrix, I can do kind of image processing work like undersampling and Gaussian kernel processing on the matrix of the depth image.
Apologies for the delay in responding further, as I was considering and researching your case.
Would using pixels_buffer to generate an nxm matrix of pixels from the raw depth data in Z16 format meet your needs?
https://github.com/IntelRealSense/librealsense/issues/4026#issuecomment-494855742
Thanks for your replying, I will have a try.
Thanks for your help. It really helps.
Another question...
Since I have included
<opencv2/imgproc/imgproc.hpp>, <opencv2/core/core.hpp>, <opencv2/highgui/highgui.hpp>, <librealsense2/rs.hpp>
When I did like
auto depth_mat = depth_frame_to_meters(pipe, depth_frame);
I got error: C++ identifier "depth_frame_to_meters" is undefined. Also,
float distanceTocam = depth_frame.get_distance(x,y);
Error: C++ class has no member "get_distance".
I was confused about that.
I'm not sure about this one. Though if you are accessing OpenCV, you may find the OpenCV-using depth example in the link below helpful as a reference. For example, the developer of that program includes realsense.h
https://github.com/UnaNancyOwen/RealSense2Sample/tree/master/sample/Depth
The version of my opencv is 3.0.0 and my OS is x86 because another library included must be based on x86. I am not sure if the version of opencv is too low. Because the function depth_frame_to_meters included in cv-helpers.hpp said "RealSense examples have been desinged and tested with OpenCV 3.4, Working with latest OpenCV 4 requires minor code changes". https://github.com/IntelRealSense/librealsense/tree/c3c758d18c585a237bb5b635927797aa69996391/wrappers/opencv
The release-notes documentation for OpenCV 3.4.9 says that the Windows installer (link below) is 32-bit, and that 64-bit users of that version need to compile OpenCV from source code.
https://sourceforge.net/projects/opencvlibrary/files/3.4.9/opencv-3.4.9-vc14_vc15.exe/download
Hi @Ted-EE Do you require further assistance with this case please?
Case closed due to no further comments received.
Issue Description
I would like to print the matrix of the depth image of one frame for some image processing work. With Python, I made it work.
`
`
However, when it came to C++, I could not do it. When I modified the while (waitKey(10000) && cvGetWindowHandle(depth_win)) to for(int i = 0; i<100; i++) loop just as written in Python, it did not work.
`
int getDepth() try {
} catch (const rs2::error& e) { std::cout << "RealSense error calling" << e.get_failed_function() << "(" << e.get_failed_args() << "):\n" << e.what() << endl; return EXIT_FAILURE; } catch (const std::exception& e) { std::cout << e.what() << endl; return EXIT_FAILURE; }
`
Thanks.