3d Point Cloud forming like a prism

7 ビュー (過去 30 日間)
Pooshpanja Roy
Pooshpanja Roy 2016 年 6 月 18 日
編集済み: Munin 2022 年 3 月 28 日
Dear All I am trying to plot a point cloud in Matlab 2016. The point cloud is forming something like this instead of a regular point cloud. Can anyone help me with why this is happening?
Thank you
My code
clear all
close all
%%Load the Parameters of the Stereo Camera
% Load the |stereoParameters| object, which is the result of calibrating
% the camera using either the |stereoCameraCalibrator| app or the
% |estimateCameraParameters| function.
% Load the stereoParameters object.
load('webcam.mat');
% Visualize camera extrinsics.
showExtrinsics(stereoParams);
% %%Create Video File Readers and the Video Player
% % Create System Objects for reading and displaying the video
% videoFileLeft = 'second_1.mp4';
% videoFileRight = 'first_1.mp4';
%
% readerLeft = vision.VideoFileReader(videoFileLeft, 'VideoOutputDataType', 'uint8');
% readerRight = vision.VideoFileReader(videoFileRight, 'VideoOutputDataType', 'uint8');
% player = vision.DeployableVideoPlayer('Location', [20, 400]);
%%Read and Rectify Video Frames
% The frames from the left and the right cameras must be rectified in order
% to compute disparity and reconstruct the 3-D scene. Rectified images
% have horizontal epipolar lines, and are row-aligned. This simplifies
% the computation of disparity by reducing the search space for matching
% points to one dimension. Rectified images can also be combined into an
% anaglyph, which can be viewed using the stereo red-cyan glasses to see
% the 3-D effect.
frameLeft = imread('first.jpg');
frameRight = imread('second.jpg');
[frameLeftRect, frameRightRect] = ...
rectifyStereoImages(frameLeft, frameRight, stereoParams);
figure;
imshow(stereoAnaglyph(frameLeftRect, frameRightRect));
title('Rectified Video Frames');
%%Compute Disparity
% In rectified stereo images any pair of corresponding points are located
% on the same pixel row. For each pixel in the left image compute the
% distance to the corresponding pixel in the right image. This distance is
% called the disparity, and it is proportional to the distance of the
% corresponding world point from the camera.
frameLeftGray = rgb2gray(frameLeftRect);
frameRightGray = rgb2gray(frameRightRect);
disparityMap = disparity(frameLeftGray, frameRightGray);
figure;
imshow(disparityMap, [0, 64]);
title('Disparity Map');
colormap jet
colorbar
%%Reconstruct the 3-D Scene
% Reconstruct the 3-D world coordinates of points corresponding to each
% pixel from the disparity map.
points3D = reconstructScene(disparityMap, stereoParams);
% Convert to meters and create a pointCloud object
points3D = points3D ./ 1000;
ptCloud = pointCloud(points3D, 'Color',frameLeftRect);
%
% % Create a streaming point cloud viewer
% player3D = pcplayer([-3, 3], [-3, 3], [0, 8], 'VerticalAxis', 'y', ...
% 'VerticalAxisDir', 'down');
%
% % Visualize the point cloud
% % view(player3D, ptCloud);
% pcshow(ptCloud.Location,ptCloud.Color);
figure
pcshow(ptCloud, 'VerticalAxis', 'y', 'VerticalAxisDir', 'down', ...
'MarkerSize', 45);
% filename='xxx.ply';
% pcwrite(ptCloud,filename,'PLYFormat','binary');

回答 (2 件)

Qiuheng Zhou
Qiuheng Zhou 2019 年 2 月 8 日
編集済み: Walter Roberson 2020 年 3 月 14 日
Hi, i think, i have the same problem as yours. Do you have already solved your problem?
I guess the problem should be hier.
ptCloud = pointCloud(points3D, 'Color',frameLeftRect);
The algorithm of KNN should be changed. I am not sure.
  1 件のコメント
Munin
Munin 2021 年 8 月 30 日
編集済み: Munin 2022 年 2 月 19 日
@Walter Roberson @Qiuheng Zhou @Pooshpanja Roy I've got a bulletproof workaround, and I've contacted the Mathworks team:

サインインしてコメントする。


Munin
Munin 2022 年 3 月 28 日
編集済み: Munin 2022 年 3 月 28 日
I contacted the MATLAB support team about this issue and told them I wrote a few dozen lines of code to constrain the giant prism point cloud to the world scene at its z-apex:
https://github.com/SNDST00M/stereo2stl/blob/v1.5.0/script.m#L216-L380
They didn't accept the code and suggested a simple > 3m = 0 filter. I.e. it will never be patched. The world scene is the millionth of the point cloud surface that is closest to the origin

Community Treasure Hunt

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

Start Hunting!

Translated by