Post Go back to editing

# Point cloud or depth map export to Matlab

Is it possible to get the point cloud exported to Matlab?

The "aditof_imaq.m" Matlab example and the built-in "image acquisition tool" work well. The depth map image and IR image stream is nice, but I miss data stream/export. In special the point cloud or depth map data.

Thanks for help :-)!

• May you please repeat my measurement (near-mode) of a box in ~40cm distance and present your RGB and Grayscale depth map and converted point cloud? Because I see circles (RGB and Grayscale), when I measure a flat surface. As I understand, this means the distance is from the middlepoint of the camera and a conversion is therefore necessary...

• Hello, we will update the script and come back with an answer as soon as possible.

• Hello, to begin with, please checkout at the latest master.

After you run aditof_imaq.m please export the data as MONO16 and select RawDepth format.
After that you ca run the following script and the data should look alright.

```%% Convertion depth map into point cloud - version B
close all; clear all; clc

% Range: <6m
% FoV: 90° x 69.2°
% Near: 25cm – 80cm
% Medium: 30cm – 4.5m
% Far: 3m – 6m
% Resolution: 640 x 480 pixels

p = s.depth; % uint8
depthMap = double(p)+1; % uint8 to double

figure();
imshow(p);

% FOVhDeg = 90;
n_c = 640;

% FOVvDeg = 69.2;
n_r = 480;

xyzPointsFromDepthMap = zeros(n_c*n_r,3);
i=1;
for yPixel = 1:480
for xPixel = 1:640
% Calculate x-coordinate
xyzPointsFromDepthMap(i,1) = xPixel; % x value

% Calculate y-coordinate
xyzPointsFromDepthMap(i,2) = yPixel; % y value

% Calculate z-coordinate
xyzPointsFromDepthMap(i,3) = depthMap(yPixel,xPixel) / 10; % z value
i = i+1;
end
end

ptCloud = pointCloud(xyzPointsFromDepthMap);

%% Plot point cloud
figure
pcshow(ptCloud);
title('ToF point cloud from depth map')
set(gca, 'Zdir', 'reverse')
xlabel('X')
ylabel('Y')
zlabel('Z')
colorbar

figure
pcshow(ptCloud);
colormap('gray');
title('ToF point cloud from depth map')
set(gca, 'Zdir', 'reverse')
xlabel('X')
ylabel('Y')
zlabel('Z')
colorbar```

Best regards,
Septimiu.

• After I run aditof_imaq.m, the image acquisition toolbox opens automatically. There I see no option to export it as MONO16, neither RawDepth format

The changes you made in the script (1. divide depth by 10, and 2. flip the z-axis), I unfortunately do not understand why that should solve my distortion problem..

I am very thankful for your help! But now I have invested so many hours in that.. and still many open, unanswered questions (like: is the depth shown in the depthMap the distance to the center-point of the camera or to the xy-plane?).

• Hello, please use the latest master from https://github.com/analogdevicesinc/aditof_sdk and not the v2.0.0 since there were updates made since that release one of which is the update for matlab.

The distance division was required so that the space would't be altered and the shown distance would be in cm. The inversion of axis was required so that the points at a higher distance would be represented in the background plane.

• First of all, thank you very much for still supporting this feed!
In the github repository it says that the v2.0.0 is the latest release. As you recommend, I used now the version 2.0.1 (pre-release).
When I change the dlls back to version 2.0.0 it runs again, but still with round circles representing a flat wall...

• Hello, sorry for the delay, we have updated the files from: