Advertisement
Kali_prasad

v2 fmd with voice feedback

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