Bounding box of face and both eyes on an image

1 view (last 30 days)
I am working on face and left and right eyes detection. I've faced the problem that bounding boxes of face and eyes are not create on image here i can write a code
clc
clear all
close all
cam = webcam;
%%To detect Face and Left and Right eye
Face_Detect = vision.CascadeObjectDetector;
Eye_Left_Detect = vision.CascadeObjectDetector('LeftEyeCART','MergeThreshold',16);
Eye_Right_Detect = vision.CascadeObjectDetector('RightEyeCART','MergeThreshold',16);
while(1)
%%Read the input image
I = snapshot(cam);
%Returns Bounding Box values
face_dtect = step(Face_Detect,I);
left_eye_dtect = step(Eye_Left_Detect,I);
right_eye_dtect = step(Eye_Right_Detect,I);
all_points = [face_dtect(1,:);left_eye_dtect(1,:);right_eye_dtect(1,:)];
IFaces = insertObjectAnnotation(I, 'rectangle',all_points,'detection');
imshow(IFaces);
end
the error is that
Attempted to access face_dtect(1,:); index out of bounds because
size(face_dtect)=[0,4].
Error in main_face (line 29) all_points = [face_dtect(1,:);left_eye_dtect(1,:);right_eye_dtect(1,:)];

Answers (1)

John D'Errico
John D'Errico on 29 Jul 2017
If you read the help for
help insertObjectAnnotation
You will find it uses FOUR arguments. You are trying to call it with only THREE arguments.
Read the error message!
  2 Comments
Abdul Basit Jaweed
Abdul Basit Jaweed on 30 Jul 2017
I put also the four input parameters but still another error occur i edit my code with 4 input parameters
Marjan Trutschl
Marjan Trutschl on 30 Sep 2020
Why the exclamation? Do you have a nice example for Abdul?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!