Effacer les filtres
Effacer les filtres

Point Cloud from DEPTH and RGB image

18 vues (au cours des 30 derniers jours)
minehaha
minehaha le 13 Avr 2019
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');

Réponses (2)

Andrej Satnik
Andrej Satnik le 2 Mai 2020
Modifié(e) : Andrej Satnik le 2 Mai 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
  1 commentaire
muhammad siddique
muhammad siddique le 8 Sep 2021
@Andrej where in code you read rgb image?

Connectez-vous pour commenter.


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

Community Treasure Hunt

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

Start Hunting!

Translated by