error message : Index exceeds matrix dimensions

1 次查看(过去 30 天)
load('callast.mat');
vid = videoinput('macvideo', 1, 'YCbCr422_1280x960');%left
vid2 = videoinput('macvideo', 2, 'YCbCr422_1280x960');%right
I1 = getsnapshot(vid);
I2 = getsnapshot(vid2);
faceDetector = vision.CascadeObjectDetector;
face1 = faceDetector(I1);
face2 = faceDetector(I2);
center1 = face1(1:2) + face1(3:4)/2;
center2 = face2(1:2) + face2(3:4)/2;
point3d = triangulate(center1, center2, stereoParams);
distanceInMeters = norm(point3d)/1000;
distanceAsString = sprintf('%0.2f meters', distanceInMeters);
I1 = insertObjectAnnotation(I1,'rectangle',face1,distanceAsString,'FontSize',18);
I2 = insertObjectAnnotation(I2,'rectangle',face2, distanceAsString,'FontSize',18);
I1 = insertShape(I1,'FilledRectangle',face1);
I2 = insertShape(I2,'FilledRectangle',face2);
imshowpair(I1, I2, 'montage');
i am trying to acquire images from stereo-cameras and detect faces with distance and i keep getting this error ...
Index exceeds matrix dimensions.
Error in lllss (line 20) center1 = face1(1:2) + face1(3:4)/2;

回答(1 个)

Image Analyst
Image Analyst 2017-12-24
Well clearly face1 does not have 4 elements like you assumed. Use normal debugging procedures to find out what it is. It might even be null/empty.

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for USB Webcams 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by