1. How to make IF statement for im.MergeThreshold use in Viola-Jones Algorithm

조회 수: 1 (최근 30일)
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.

채택된 답변

Florian Morsch
Florian Morsch 2018년 5월 18일
편집: Florian Morsch 2018년 5월 18일
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
Amirul Ibrahim
Amirul Ibrahim 2018년 5월 21일
Thanks a lot. This works for one of my application using it.
amina benameur
amina benameur 2021년 6월 16일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by