3d Point Cloud forming like a prism
1 次查看(过去 30 天)
显示 更早的评论
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');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154126/image.jpeg)
0 个评论
回答(2 个)
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
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Point Cloud Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!