1
+ classdef FaceMaskDetection < vision .labeler .AutomationAlgorithm
2
+
3
+ properties (Constant )
4
+
5
+ Name = ' Face Mask Detection' ;
6
+ Description = ' This is a automatic Mask labeling algorithm.' ;
7
+
8
+ UserDirections = {...
9
+ [' Automation algorithms are a way to automate manual labeling ' ...
10
+ ' tasks. This AutomationAlgorithm is a template for creating ' ...
11
+ ' user-defined automation algorithms. Below are typical steps' ...
12
+ ' involved in running an automation algorithm.' ], ...
13
+ [' Run: Press RUN to run the automation algorithm. ' ], ...
14
+ [' Review and Modify: Review automated labels over the interval ' , ...
15
+ ' using playback controls. Modify/delete/add ROIs that were not ' ...
16
+ ' satisfactorily automated at this stage. If the results are ' ...
17
+ ' satisfactory, click Accept to accept the automated labels.' ], ...
18
+ [' Change Settings and Rerun: If automated results are not ' ...
19
+ ' satisfactory, you can try to re-run the algorithm with ' ...
20
+ ' different settings. In order to do so, click Undo Run to undo ' ...
21
+ ' current automation run, click Settings and make changes to ' ...
22
+ ' Settings, and press Run again.' ], ...
23
+ [' Accept/Cancel: If results of automation are satisfactory, ' ...
24
+ ' click Accept to accept all automated labels and return to ' ...
25
+ ' manual labeling. If results of automation are not ' ...
26
+ ' satisfactory, click Cancel to return to manual labeling ' ...
27
+ ' without saving automated labels.' ]};
28
+ end
29
+
30
+ properties
31
+
32
+ AllCategories = {' background' };
33
+ FireName
34
+ count
35
+
36
+
37
+ end
38
+
39
+ methods
40
+ function isValid = checkLabelDefinition(algObj , labelDef )
41
+
42
+ disp([' Executing checkLabelDefinition on label definition "' labelDef .Name ' "' ])
43
+
44
+ if (strcmpi(labelDef .Name , ' Mask' ) && labelDef .Type == labelType .Rectangle )
45
+ isValid = true ;
46
+ algObj.FireName = labelDef .Name ;
47
+ algObj.AllCategories{end + 1 } = labelDef .Name ;
48
+ end
49
+
50
+
51
+ end
52
+
53
+ function isReady = checkSetup(algObj )
54
+
55
+ isReady = ~isempty(algObj );
56
+
57
+
58
+
59
+ end
60
+
61
+ function settingsDialog(algObj )
62
+
63
+ disp(' Executing settingsDialog' )
64
+
65
+ end
66
+ end
67
+
68
+ methods
69
+
70
+ function initialize(algObj , I )
71
+
72
+ disp(' Executing initialize on the first image frame' )
73
+
74
+ end
75
+
76
+ function autoLabels = run(algObj , I )
77
+
78
+ disp(' Executing run on image frame' )
79
+
80
+ [labelCord , label ] = MaskLabel(I , algObj );
81
+ autoLabels.Name = char(label );
82
+ autoLabels.Type = labelType(' Rectangle' );
83
+ autoLabels.Position = labelCord ;
84
+ algObj.count = algObj .count + 1 ;
85
+
86
+ end
87
+
88
+ function terminate(algObj )
89
+
90
+ disp(' Executing terminate' )
91
+
92
+ end
93
+ end
94
+ end
95
+ % Copyright 2020 The MathWorks, Inc.
0 commit comments