Hi, I have a problem. I wrote a code that recognizes faces, mouths and noses. Now I can't write the code that, if the code doesn't find out the mouth and nose in a photo, will tell that the person is wearing something on them. Thanks

1 次查看(过去 30 天)
FDetect = vision.CascadeObjectDetector;
I = imread ('Test 3.jpg');
figure(1),imshow(I);
title ('foto da analizzare');
BB = step(FDetect,I);
figure(2),
imshow (I); hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
end
title ('focalizzazione volto');
hold off;
NoseDetect = vision.CascadeObjectDetector('Nose','MergeThreshold',16);
BB=step(NoseDetect,I);
figure(3),
imshow(I);hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','b');
end
title ('focalizzazione naso');
hold off;
MouthDetect = vision.CascadeObjectDetector('Mouth','MergeThreshold',16);
BB=step(MouthDetect,I);
figure(4),
imshow(I);hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','g');
end
title ('focalizzazione bocca');
hold off;

回答(1 个)

Mehmed Saad
Mehmed Saad 2020-5-6
编辑:Mehmed Saad 2020-5-6
I am assuming a single person face for this purpose
After detection of the face, the next thing to do is detect nose (now do not detect nose if face doesn't exist and donot apply that on the whole picture )

Nose Detection

In nose detection, the position of nose is BB in imaga I given by NoseDetect which is
BB=step(NoseDetect,I);
Now remember if BB is empty it means no nose is detected in the current figure and if BB is not empty nose is detected.
Hint: isempty, save value of nose detected or not in a variable
Follow a simialr step for mouth (you may need to change threshold of mouth detection)
Now suppose i have two variables, one for nose_detected and other for mouth_detected.
Hint: they will be boolean
so now at the end of the code you can (and) both variable and tell if a person is wearing mask or not

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by