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
  댓글 수: 1
Andrea Verardi
Andrea Verardi 2020년 5월 6일
I understand what you meant, but which is the code to have the result you had in the fisrt picture you posted?
Thank you in advance

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

카테고리

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