1. How to make IF statement for im.MergeThreshold use in Viola-Jones Algorithm
3 views (last 30 days)
Show older comments
Amirul Ibrahim
on 18 May 2018
Commented: amina benameur
on 16 Jun 2021
Hi, i am trying to code an algorithm to detect facial features and extract its values.
I am using viola-jones algorithm for mouth, nose, and eyes detection. In the code, theres a threshold that is used to determine the number of detected object in the image. My problem is, when i input a new image, the algorithm cannot detect the features. Only when i change the threshold value will it detect. The values i specifies are random and are by trial and error. Are there a way for using an if or switch case statement for it to automatically try other threshold value? I am using a normalized 100x100 grayscale images of already cropped out face from original image to detect the eyes, nose, mouth.
example code:
mouthdetect = vision.CascadeObjectDetector('Mouth');
% Threshold value //CHANGE HERE IF ROI IS NOT DETECTED
mouthdetect.MergeThreshold = 50;
% Detects mouth in image.
bb_m = step(mouthdetect, face);
% Annotation
an_m = insertObjectAnnotation(face, 'rectangle', bb_m, 'Mouth');
% Crop segmented mouth
mouth = imcrop(face, bb_m);
2. Also, does anyone know what should i extract from gabor filtered image for expression recognition? I've read some research that uses std, var, pca, dct. But i get an array of values not a single value.
0 Comments
Accepted Answer
Florian Morsch
on 18 May 2018
Edited: Florian Morsch
on 18 May 2018
You can check your variables if they have values in them. If not, change the threshold and run again.
1. Create a flag, like "FaceFound = 0"
2. Use a while:
mouthdetect = vision.CascadeObjectDetector('Mouth');
mouthdetect.MergeThreshold = 1; % Threshold value, starts at 1 or any value you want
FaceFound = 0;
while FaceFound = 0
bb_m = step(mouthdetect, face); % Detects mouth in image.
if(bb_m == []) % Check if a mouth is found, if not increase the Threshold by 1
mouthdetect.MergeThreshold = mouthdetect.MergeThreshold + 1;
else
an_m = insertObjectAnnotation(face, 'rectangle', bb_m, 'Mouth'); % Annotation
mouth = imcrop(face, bb_m); % Crop segmented mouth
FaceFound = 1;
end
end
This way your programm will run as long as there is nothing found and increase the threshold. After a mouth is found the loop ends.
Remember to reset the variables before you run the loop again, if you still have values in your workspace you might get wrong results.
2 Comments
amina benameur
on 16 Jun 2021
I am a graduate student at the University of Science and Technology Mohamed Boudiaf in Oran in Algeria and I am doing research in the theme Analysis of shape and texture of facial regions for the recognition of expressions.
i need a viola jones algorithm
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!