Advertisement
Kali_prasad

error free code fmd v1

Apr 14th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.00 KB | None | 0 0
  1. clc
  2.  
  3. close all;
  4. cam=webcam(1);
  5.  
  6. e=cam.snapshot;
  7. FDetect=vision.CascadeObjectDetector('Mouth','MergeThreshold',100);
  8. I=e;
  9. BB_Mouth=step(FDetect,I);
  10. imshow(I);
  11. hold on;
  12. %%
  13. FDetect=vision.CascadeObjectDetector('Nose','MergeThreshold',16);
  14. I=e;
  15. BB_Nose=step(FDetect,I);
  16. imshow(I);
  17. hold on;
  18. if(sum(sum(BB_Nose))==0 && sum(sum(BB_Mouth))==0)
  19.     FDetect=vision.CascadeObjectDetector('FrontalFaceLBP','MergeThreshold',10);
  20.     BB_Mouth=step(FDetect,I);
  21.     if(sum(sum(BB_Mouth))~=0)
  22.     title('Remove Hand Please');
  23.     defaultString = 'Remove Hand from face.';
  24.     NET.addAssembly('System.Speech');
  25.     obj = System.Speech.Synthesis.SpeechSynthesizer;
  26.     obj.Volume = 100;
  27.     Speak(obj, defaultString);
  28.     else
  29.     title('Mask Present');
  30.     defaultString = 'Thank You for wearing Mask.';
  31.     NET.addAssembly('System.Speech');
  32.     obj = System.Speech.Synthesis.SpeechSynthesizer;
  33.     obj.Volume = 100;
  34.     Speak(obj, defaultString);
  35.     end
  36. elseif((sum(sum(BB_Nose))~=0 && sum(sum(BB_Mouth))==0)||(sum(sum(BB_Nose))==0 && sum(sum(BB_Mouth))~=0))
  37.    for i=1:size(BB_Nose,1)
  38.    rectangle('Position',BB_Nose(i,:),'Linewidth',5,'LineStyle','-','EdgeColor','r');
  39.    end
  40.    for i=1:size(BB_Mouth,1)
  41.    rectangle('Position',BB_Mouth(i,:),'Linewidth',5,'LineStyle','-','EdgeColor','r');
  42.    end
  43.     title('Please wear mask properly');
  44.     defaultString = 'Please wear mask properly.';
  45.     NET.addAssembly('System.Speech');
  46.     obj = System.Speech.Synthesis.SpeechSynthesizer;
  47.     obj.Volume = 100;
  48.     Speak(obj, defaultString);
  49. else
  50.    for i=1:size(BB_Nose,1)
  51.    rectangle('Position',BB_Nose(i,:),'Linewidth',5,'LineStyle','-','EdgeColor','r');
  52.    end
  53.    for i=1:size(BB_Mouth,1)
  54.     rectangle('Position',BB_Mouth(i,:),'Linewidth',5,'LineStyle','-','EdgeColor','r');
  55.     end
  56.     title('Please wear Mask');
  57.     defaultString = 'Please wear Mask.';
  58.     NET.addAssembly('System.Speech');
  59.     obj = System.Speech.Synthesis.SpeechSynthesizer;
  60.     obj.Volume = 100;
  61.     Speak(obj, defaultString);
  62. end
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement