Point Cloud from DEPTH and RGB image

24 visualizaciones (últimos 30 días)
minehaha
minehaha el 13 de Abr. de 2019
Respondida: Preetham Manjunatha el 4 de Oct. de 2022
Hi everyone, my aim is to create a point cloud from depth image and RGB image I obtained from kinect. Successfully I calculated coordinates and visualised depth map as a cloud, but dont know how to add the color information from RGB.
Is there a way how to insert RGB matrix as a color parameter of ptCloud?
%ptCloud = pointCloud(points,'Color',cmatrix);
I found
scatter3
plot in discussion, but in my case it doesnt show correct values.
Any advice?
Thank you
clearvars
%load depth
final{1}=['FinalKamera.hdr'];
linear = hdrread(final{1});
linear = linear(:, :, 1);
%load rgb
rgb = imread('FinalKamerargb.jpeg');
% depth coordinates calculation
points=zeros(512*424,3);
inc=1;
for i=1:424
for j=1:512
points(inc,1)=(i-256.4626)*linear(i,j)/(365.3277); % x array
points(inc,2)=(j-213.1488)*linear(i,j)/(366.8126); % y array
points(inc,3)= linear(i,j); % z array
inc=inc+1;
end
end
%ptCloud = pointCloud(points,'Color',cmatrix);
%pcshow(points);
clr = reshape(double(rgb)/255, [], 3);
scatter3(points(:,1), points(:,2), points(:,3), 6, clr, '.')
axis tight vis3d
title('Point Cloud'); xlabel('X'); ylabel('Y'); zlabel('Z');

Respuestas (2)

Andrej Satnik
Andrej Satnik el 2 de Mayo de 2020
Editada: Andrej Satnik el 2 de Mayo de 2020
This post is old but for anyone who is searching for the answer this is faster method without loops. Correct me if I am wrong.
%depth is depth image in double format
Sd = size(depth);
[X,Y] = meshgrid(1:Sd(2),1:Sd(1));
%K is calibration matrix
X = X - K(1,3) + 0.5;
Y = Y - K(2,3) + 0.5;
XDf = depth/K(1,1);
YDf = depth/K(2,2);
X = X .* XDf;
Y = Y .* YDf;
XY = cat(3,X,Y);
cloud = cat(3,XY,depth);
cloud = reshape(cloud,[],3) / 1000.0;
% if you can use matlab point cloud library
cloud = pointCloud(cloud);
pcshow(cloud);
Happy coding.
Best Andrej

Preetham Manjunatha
Preetham Manjunatha el 4 de Oct. de 2022
This link can help to convert RGB-D images to point cloud, provided the camera intrinsic parameters.

Categorías

Más información sobre Point Cloud Processing en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by