- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
How can I acquire a depth image in MATLAB with the actual depth values? Depth_example.m demonstrates how to acquire a depth stream and colorize for visualization, but I need the real depth values in units of length. For example, I would like a 840x480 image where each pixel value is the depth in mm or meters, or alternatively an image where each pixel value is an integer and we have the corresponding depth scale factor. I've seen the C++ examples, but it is not clear how these translate to MATLAB.
Thank you.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Got it... hope this helps someone else.
% Make Pipeline object to manage streaming
pipe = realsense.pipeline();
% Start streaming on an arbitrary camera with default settings
profile = pipe.start();
% Get streaming device's name
dev = profile.get_device();
name = dev.get_info(realsense.camera_info.name);
% Get frames. We discard the first couple to allow
% the camera time to settle
for i = 1:5
fs = pipe.wait_for_frames();
end
% Stop streaming
pipe.stop();
% Select depth frame
depth = fs.get_depth_frame();
% get depth image parameters
depthSensor = dev.first('depth_sensor');
depthScale = depthSensor.get_depth_scale();
depthWidth = depth.get_width();
depthHeight = depth.get_height();
% retrieve UINT16 depth vector
depthVector = depth.get_data();
% reshape vector, and scale to depth in meters
depthMap = double(transpose(reshape(depthVector, [depthWidth,depthHeight]))) .* depthScale;
figure(1);
imshow(depthMap);
title('Depth Map (m)');
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
If you are satisfied with getting the depth data from an image file, an Intel support agent offered advice about getting depth in MATLAB from a .raw file created in the RealSense Viewer.
*****
In order to read a raw file produced with Intel.RealSense.Viewer.exe, use this code:
FID = fopen('IntelDepth.raw');
DepthImage = fread(FID, [1280, 720], 'uint16')';
fclose(FID);
Make sure you configure the depth image as z16 (16 bit). To capture a stream of images, use the record button.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Thanks Marty. I've seen this solution and it works very well, but for my application I need to stream real depth images directly into MATLAB.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Of the commercial products available, the Image Acquisition Toolbox that Intel agent Eliza recommended in your MATLAB RGB point cloud post is the most likely paid solution for what you want ti achieve.
https://uk.mathworks.com/products/imaq.html
Alternatively, MATLAB has a 'Robotics System Toolbox' for interfacing with ROS.
https://uk.mathworks.com/products/robotics.html
The ideal situation would be to do it via the RealSense SDK MATLAB wrapper, if you can use Windows 10. I am not an expert in MATLAB wrapper programming, unfortunately. To avoid getting colorization, a 'hacky' approach might be to delete line 26 of the depth colorizer example that initiates the colorizing, and see if that gives you a non-colorized stream.
https://github.com/IntelRealSense/librealsense/blob/master/wrappers/matlab/depth_example.m#L26
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I agree - one would reasonably expect to retrieve depth values from the MATLAB SDK wrapper. Unfortunately, commenting line 26 doesn't work, since the 'color' object is used in line 30 to retrieve the data. Hopefully, someone from the RealSense team will see this and respond.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Got it... hope this helps someone else.
% Make Pipeline object to manage streaming
pipe = realsense.pipeline();
% Start streaming on an arbitrary camera with default settings
profile = pipe.start();
% Get streaming device's name
dev = profile.get_device();
name = dev.get_info(realsense.camera_info.name);
% Get frames. We discard the first couple to allow
% the camera time to settle
for i = 1:5
fs = pipe.wait_for_frames();
end
% Stop streaming
pipe.stop();
% Select depth frame
depth = fs.get_depth_frame();
% get depth image parameters
depthSensor = dev.first('depth_sensor');
depthScale = depthSensor.get_depth_scale();
depthWidth = depth.get_width();
depthHeight = depth.get_height();
% retrieve UINT16 depth vector
depthVector = depth.get_data();
% reshape vector, and scale to depth in meters
depthMap = double(transpose(reshape(depthVector, [depthWidth,depthHeight]))) .* depthScale;
figure(1);
imshow(depthMap);
title('Depth Map (m)');

- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite