Point cloud or depth map export to Matlab

I use AD-96TOF1-EBZ (with dragonboard)

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 :-)!

Parents Reply
  • 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
    
    s = load('depthMat.mat');
    p = s.depth; % uint8
    depthMap = double(p)+1; % uint8 to double
    
    figure();
    imshow(p);
    
    % FOVhDeg = 90;
    % FOVhRad = deg2rad(FOVhDeg);
    n_c = 640;
    
    % FOVvDeg = 69.2;
    % FOVvRad = deg2rad(FOVvDeg);
    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.

Children