Output Video :-
Step 1 :- Image Labeling using Image labeler app
Drawing Rectangle into the Face mask Region
Steps :-
1.Face mask images of our own with different Background,Side Face,Frontal Face and Also you can Download Face Mask Images from the Internet but make sure they look Original not much Processed.
You can also Download FACE Mask images for Free :-
300 images :- Download Here
2. Labelling in Image labeler App.
Labelling means:- Drawing Rectangle Bounding Box around Face.
3.Exporting Labeled Images
4.Training ACF object Detector to Certain Stages.
5.Testing our AI on Unlabelled Images.
Implementation
Step 1:- Collect Sample Face images either Face dataset available on internet or Of your Own Images with different Backrounds and Light Conditions also.
Around 200-300 Faces MAsk images are more than Enough for Training Our Detector.
Warning:- Dont Use Images with same Background and Filtered Images from Insta or any such photo edited app.
Step 2:- Open MATLAB
Open Image labeler App by Clicking on APP icon and searching for image labeler.
Note :-Image labeler app is available on Latest Versions of MATLAB like 2017,2018,2019,2020 MATLAB Versions.
By Drawing Rectangle box i.e Boundary or Bounded Box on Face region of Image.
Now, After Labeling ,The AI extracts Features from the Bounding Box like Shape of Nose,Eyes,Mouth & Skin color.
We also need to supply Negative Images i.e images not having face,
so AI can learn to find Difference what a FACE is and What features face doesnt have.
But, We are using ACF Object detector which doesnt Requires Negative Images, Only Positive Image with Labeling Face region are enough.
ACF Detector Creates its own Negative examples to Train.
Step 3:- Export Labeled images &
Load it in MATLAB, By Writing Command.
load('face.mat');
Step 4 :- Make Training Data folder ,
use Command to Train ACF DETECTOR..
CODE is Given in Video and also below .
ACF detector requires 10-20 Stages and it takes around
10-20 minutes .
Once Detector is detected ,u can use it to detect faces in images as well as In Video
FACE MASK Tracking CODE:-
load('Mask.mat');
% 1. Load labelled data file ,which created through image labelling
FaceMask = selectLabels(gTruth,'Mask');
% 2. Creating Variable FaceGtruth in which will store labels 'Face'
if isfolder(fullfile('TrainingData'))
cd TrainingData
else
mkdir TrainingData
end
addpath('TrainingData');
% 3. if else condition, if means 'if full name TrainingData exist ,locate that file ' else here if TrainingData Files doesnt exits Make one and
% add it to the MATLAB Path
trainingData = objectDetectorTrainingData(Faceamsk,'SamplingFactor',1,'writeLocation','TrainingData');
detector = trainACFObjectDetector(trainingData,'NumStages',20);
save('Detector.mat','detector');
rmpath('TrainingData');
% Make variable trainingData in which will store and passing Parameters like FaceGtruth that is labels , Sampling factor means Examples Face images
% if sampling factor is 2 than 2times negative images taken, Writing location = as TrainingData Folder
load('Detector.mat');
% load Trained Object Detector
vidReader = VideoReader('C:\Users\ANKIT TIWARI\Desktop\Face detection UTUBE\face Rawdata\faceMask.mp4');
% VideoReader is for reading Video
vidPlayer = vision.DeployableVideoPlayer;
% Play Video in MATLAB
i = 1;
results = struct('Boxes',[],'Scores',[]);
% results is variable for storing bounding box i.e rectangle values
while(hasFrame(vidReader))
% While loop
I = readFrame(vidReader);
[bboxes, scores] = detect(detector,I,'Threshold',1);
[~,idx] = max(scores);
results(i).Boxes = bboxes;
results(i).Scores = scores;
annotation = sprintf('Mask' ,detector.ModelName,scores(idx));
I = insertObjectAnnotation(I,'rectangle',bboxes(idx,:),annotation);
step(vidPlayer,I);
i =i+1;
end
results = struct2table(results);
Other Articles :-
Scope of Biomedical in India
https://biomedicalengineeringscopeinindia.blogspot.com/
Covid Face Mask Tracking in Matlab
http://covidfacemaskdetectioninmatlab.blogspot.com/2021/02/blog-post.html
https://biomedicaljobsinindia.blogspot.com/2018/03/biomedical-engineering-job-options-in.html
Face tracking in Matlab using ACF Object detector and Image Labeler
Contactless Water Level indicator & Alarm for Water tank overflow
http://watertankoverflowalarm.blogspot.com/2021/02/blog-post.html
Comments
Post a Comment