output_dir = 'C:\Users\HITESH\Desktop\Matlab';
objects = imaqfind;
%%set up webcam
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
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
pcshow(pointCloud, J1, 'VerticalAxis', 'Y', 'VerticalAxisDir', 'Down', 'Parent', ax);
xlabel('X (m)');
ylabel('Y (m)');
zlable('Z (m)');
xlim(ax, [-.8, .8]);
ylim(ax, [-.8, .8]);
zlim([ax, maxDepth]);
drawnow;
end
end
release(leftCam);
release(rightCam);
Trying to create 3d point cloud from live feed using two calibrated usb camera, but the following error occurs:
Error using load
Unable to read file 'stereocalibration'. No such file or directory.
matlab R2015a

2 commentaires

Walter Roberson
Walter Roberson le 15 Fév 2019
run stereoCameraCalibrator . save from the menu . Assign stereoParameters to stereoParams . Save that into stereocalibration.mat
KALYAN ACHARJYA
KALYAN ACHARJYA le 15 Fév 2019
Read the error, what does it say
Unable to read file 'stereocalibration'. No such file or directory.
Ensure that, the file stereocalibration is avaliable in current working directory.

Connectez-vous pour commenter.

Réponses (0)

Question posée :

le 15 Fév 2019

Commenté :

le 15 Fév 2019

Community Treasure Hunt

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

Start Hunting!

Translated by