Clear Filters
Clear Filters

error message : Index exceeds matrix dimensions

1 view (last 30 days)
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;

Answers (1)

Image Analyst
Image Analyst on 24 Dec 2017
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.

Categories

Find more on Image Processing and Computer Vision 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!