Implementation of Mask Use Detection With SVM and Haar Cascade in OpenCV

  • Hustinawaty Department of Informatics Engineering, Faculty of Computer Science and Information Technology, Gunadarma University, Depok, Indonesia
  • Muhammad Farell Department of Informatics Engineering, Faculty of Computer Science and Information Technology, Gunadarma University, Depok, Indonesia
Keywords: Image Processing, Video Processing, OpenCV, Haar Cascade Classifier, Face Mask Detection


Despite a decline in global COVID-19 cases, the persisting threat of SARS-CoV-2 coupled with waning public awareness of the virus threat has raised concerns. A notable number of individuals disregard mask usage or do so incorrectly. It is particularly concerning given that COVID-19 has high transmissibility, especially in crowded areas like shopping centers. Enforcement officers often face challenges in identifying those wearing masks improperly. Herein lies the significance of automated mask detection to aid enforcement officers in containing the spread of the virus. Hence, this paper aims to highlight the importance of automated mask detection in combatting COVID-19 transmission. Previous mask detection algorithms were intricate because they relied heavily on resource-intensive machine learning algorithms and libraries. These algorithms, however, failed to address the problem of incorrect mask usage adequately. Therefore, despite the apparent usage of masks, the virus managed to find transmission pathways. In contrast, this research focuses on creating algorithms that pinpoint improper mask usage and optimize resource utilization without compromising detection quality. The Haar cascade algorithm was utilized to detect faces and the support vector machine (SVM) was used to train the dataset. The model attained an average accuracy of 95.8%, precision of 99.7%, recall of 92.3%, and F1-score of 93.7%. The metrics aligned with prior studies, affirming their reliability. Nevertheless, limitations exist as the model faces challenges in detecting obscured facial features, requiring further research to enhance its detection capabilities. This research contributes to ongoing efforts to improve mask detection technology for more effective virus containment.


Y. Zhu et al., “Mix contrast for COVID-19 mild-to-critical prediction,” IEEE Trans. Biomed. Eng., vol. 68, no. 12, pp. 3725–3736, Dec. 2021, doi: 10.1109/TBME.2021.3085576.

M. Akay et al., “Healthcare Innovations to address the challenges of the COVID-19 pandemic,” IEEE J. Biomed., Health Inform., vol. 26, no. 7, pp. 3294–3302, Jul. 2022, doi: 10.1109/JBHI.2022.3144941.

S. Chiera et al., “Measuring total filtration efficiency of surgical and community face masks: Impact of mask design features,” IEEE Trans. Instrum., Meas., vol. 72, pp. 1–17, Mar. 2023, doi: 10.1109/TIM.2023.3257326.

A.C. Morales et al., “Causes and consequences of purifying selection on SARS-CoV-2,” Genome Biol., Evol., vol. 13, no. 10, pp. 1–17, Oct. 2021, doi: 10.1093/gbe/evab196.

S. Taylor and G.J.G. Asmundson, “Negative attitudes about facemasks during the COVID-19 pandemic: The dual importance of perceived ineffectiveness and psychological reactance,” PloS ONE, vol. 16, no. 2, pp. 1–15, Feb. 2021, doi: 10.1371/journal.pone.0246317.

S. Lee and D. An, “Applying a deep learning enhanced public warning system to deal with COVID-19,” J. Commun., Netw., vol. 23, no. 5, pp. 350–359, Oct. 2021, doi: 10.23919/JCN.2021.000036.

E. Cave, “COVID-19 super-spreaders: Definitional quandaries and implications,” Asian Bioeth. Rev., vol. 12, no. 2, pp. 235–242, Jun. 2020, doi: 10.1007/s41649-020-00118-2.

Y. Pathak, P.K. Shukla, and K.V. Arya, “Deep bidirectional classification model for COVID-19 disease infected patients,” IEEE/ACM Trans. Comput. Biol. Bioinform., vol. 18, no. 4, pp. 1234–1241, Jul./Aug. 2021, doi: 10.1109/TCBB.2020.3009859.

N.A. Nainan et al., “Real time face mask detection using MobileNetV2 and InceptionV3 models,” 2021 IEEE Mysore Sub Sect. Int. Conf. (MysuruCon), 2021, pp. 341–345, doi: 10.1109/MysuruCon52639.2021.9641675.

I.M.D.P. Asana, G.A. Pradana, I.P.S. Handika, and S.I. Murpratiwi, “Mask detection system using convolutional neural network method on surveillance camera,” Telemat., J. Inform., Teknol. Inf., vol. 19, no. 2, pp. 201–214, Jun. 2022, doi: 10.31315/telematika.v19i2.7246.

A. Das, M.W. Ansari, and R. Basak, “COVID-19 face mask detection using TensorFlow, Keras and OpenCV,” 2020 IEEE 17th India Counc. Int. Conf. (INDICON), 2020, pp. 1¬–5, doi: 10.1109/INDICON49873.2020.9342585.

N. Ullah et al., “A novel DeepMaskNet model for face mask detection and masked facial recognition,” J. King Saud Univ. Comput. Inf. Sci., vol. 34, no. 10, pp. 9905–9914, Nov. 2022, doi: 10.1016/j.jksuci.2021.12.017.

A. Sharma, J. Pathak, M. Prakash, and J.N. Singh, “Object detection using OpenCV and Python,” 2021 3rd Int. Conf. Adv. Comput. Commun. Control, Netw. (ICAC3N), 2021, pp. 501–505, doi: 10.1109/ICAC3N53548.2021.9725638.

P. Nagrath et al., “SSDMNV2: A real time DNN-based face mask detection system using single shot multibox detector and MobileNetV2,” Sustain. Cities Soc., vol. 66, pp. 1–13, Mar. 2021, doi: 10.1016/j.scs.2020.102692.

S.O. Adeshina, H. Ibrahim, S.S. Teoh, S. Hoo, “Custom face classification model for classroom using Haar-like and LBP features with their performance comparisons,” Electron., vol. 10, no. 2, pp. 1¬–15, Jan. 2021, doi: 10.3390/electronics10020102.

H. Adusumalli et al., “Face mask detection using OpenCV,” 2021 3rd Int. Conf. Intell. Commun. Technol. Virtual Mob. Netw. (ICICV), 2021, pp. 1304–1309, doi: 10.1109/ICICV50876.2021.9388375.

D.S.A. Gundala, S.S. Alamuri, A. Firdaus, and G.K. Kumar, “Implementing augmented reality using OpenCV,” 2022 IEEE Delhi Sect. Conf. (DELCON), 2022, pp. 1–4, doi: 10.1109/DELCON54057.2022.9753233.

I. Ralev and G. Krastev, “Application of OpenCV in serious games,” 2022 Int. Symp. Multidiscip. Studies Innov. Technol. (ISMSIT), 2022, pp. 484–487, doi: 10.1109/ISMSIT56059.2022.9932804.

R.A. Asmara, M. Ridwan, and G. Budiprasetyo, “Haar Cascade and convolutional neural network face detection in client-side for cloud computing face recognition,” 2021 Int. Conf. Elect., Inf. Technol. (IEIT), 2021, pp. 1¬–5, doi: 10.1109/IEIT53149.2021.9587388.

S. Abidin, “Deteksi wajah menggunakan metode Haar cascade classifier berbasis webcam pada MATLAB,” J. Teknol. Elektrika, vol. 15, no. 1, pp. 21–27, May 2018, doi: 10.31963/elekterika.v15i1.2102.

R.Y. Adhitya et al., “Applied Haar cascade and convolution neural network for detecting defects in the PCB pathway,” 2020 Int. Conf. Comput. Eng. Netw. Intell. Multimed. (CENIM), 2020, pp. 408-411, doi: 10.1109/CENIM51130.2020.929799.

How to Cite
Hustinawaty, & Muhammad Farell. (2024). Implementation of Mask Use Detection With SVM and Haar Cascade in OpenCV. Jurnal Nasional Teknik Elektro Dan Teknologi Informasi, 13(1), 31-37.