필터 지우기
필터 지우기

Point Cloud from DEPTH and RGB image

조회 수: 18 (최근 30일)
minehaha
minehaha 2019년 4월 13일
답변: Preetham Manjunatha 2022년 10월 4일
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');

답변 (2개)

Andrej Satnik
Andrej Satnik 2020년 5월 2일
편집: Andrej Satnik 2020년 5월 2일
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
muhammad siddique
muhammad siddique 2021년 9월 8일
@Andrej where in code you read rgb image?

댓글을 달려면 로그인하십시오.


Preetham Manjunatha
Preetham Manjunatha 2022년 10월 4일
This link can help to convert RGB-D images to point cloud, provided the camera intrinsic parameters.

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by