フィルターのクリア

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 Center および File ExchangePoint Cloud Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by