3D point cloud doesn't show up.
Show older comments
I have been trying to get a Point Cloud from a live feed using 2 usb web cams with the following code.
As I run the code below a 3D plane shows up but no point cloud is displayed in that, the program keeps running for a long time but nothing comes up except the 3D plane.
MATLAB: R2015a
output_dir = 'C:\Users\HITESH\Desktop\Matlab';
%%set up webcam
delete(imaqfind)
leftCam = imaq.VideoDevice('winvideo', 2, 'YUY2_640x480');
rightCam = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480');
%%load stereo parameters if required
if ~exist('stereoParams', 'var')
load stereocalibration.m;
end
ax = axes;
maxDepth = 5;
while true
imageLeft = step(rightCam);
imageRight = step(leftCam);
[J1, J2] = rectifyStereoImages(imageLeft, imageRight, stereoParams);
disp = disparity(rgb2gray(J1), rgb2gray(J2), 'DisparityRange', [0, 112]);
pointCloud = reconstructScene(disp, stereoParams) ./1000;
z = pointCloud(:,:,3);
z(z<0) = NaN;
z(z>maxDepth) = NaN;
pointCloud(:,:,3) = z;
if ~ishandle(ax)
break;
else
showPointCloud(pointCloud, J1, 'VerticalAxis', 'Y', 'VerticalAxisDir', 'Down', 'Parent', ax);
xlabel('X (mm)');
ylabel('Y (mm)');
zlabel('Z (mm)');
xlim(ax, [-.8, .8]);
ylim(ax, [-.8, .8]);
zlim(ax, [-.8, .5]);
drawnow;
end
end
release(leftCam);
release(rightCam);
Accepted Answer
More Answers (0)
Categories
Find more on Display Point Clouds in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!