Face Detectionand Recognition Using Open CV
Face Detectionand Recognition Using Open CV
net/publication/355886757
CITATIONS READS
8 10,290
2 authors:
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Ramadan Zebari on 29 August 2023.
DOI: https://doi.org/10.30880/jscdm.2021.02.02.008
Received 21 May 2021; Accepted 05 August 2021; Available online 15 October 2021
Abstract: Intel's OpenCV is a free and open-access image and video processing library. It is linked to computer
vision, like feature and object recognition and machine learning. This paper presents the main OpenCV modules,
features, and OpenCV based on Python. The paper also presents common OpenCV applications and classifiers
used in these applications like image processing, face detection, face recognition, and object detection. Finally, we
discuss some literary reviews of OpenCV applications in the fields of computer vision such as face detection and
recognition, or recognition of facial expressions such as sadness, anger, happiness, or recognition of the gender and
age of a person.
Keywords: OpenCV, Face Detection, Object Detection, Eigenfaces, Faster R-CNN, Fisherfaces
1. Introduction
Computer Vision is one of the most fascinating and challenging tasks in the field of Artificial Intelligence.
Computer Vision serves as a link between computer software and the visuals we see around us. It enables computer
software to comprehend and learn about the visuals in its environment. As an example: The fruit is determined by its
color, shape, and size. This job may seem simple for the human brain, but in the Computer Vision pipeline, we first
collect data, then conduct data processing operations, and then train and educate the model to learn how to differentiate
between fruits based on size, shape, and color. The main goal is to identify and comprehend the images and offer new
images that are more useful for us in different life fields [1], [2].
The term "OpenCV" is an abbreviation for "open source computer vision." The architecture is made up of
software, databases, and plugins that are pre-programmed with support for integrating computer vision applications [3].
It is one of the most used toolkits with a large developer group. It is well-known for the size at which it builds real-
world usage cases for industrial use. OpenCV follows C/C++, Python, Java programming languages and can be used to
build computer vision software for desktop and smartphone platforms such as Windows, Linux, macOS, Android, and
iOS. The most recent releases are OpenCV-4.5.2 and OpenCV-3.4.14. It is free and open-source, as well as simple to
use and install. It is intended for numerical productivity with a heavy emphasis on real-time applications. The first
version was in the C programming language; however, its success increased with the release of Version 2.0, which had
a C++ implementation [2]. C++ is used to create new features. OpenCV can be downloaded for free from
http://opencv.org. This platform includes the most recent distribution update (version: 4.5.2) as well as older iterations.
Photos must be in BGR or Grayscale format in order to be displayed or saved via OpenCV. Otherwise, unfavorable
outcomes could occur [1].
Face detection is a form of computer vision that aids in detecting and visualizing facial features in captured
pictures or real-time videos. This type of object detection technique detects instances of semantic artifacts of a given
class (such as people, cars, and houses) in digital pictures and videos. Face recognition has become increasingly
important as technology has advanced, especially in fields such as photography, defense, and marketing [4], [5].
Recognition is a modern field of study that has piqued the interest of researchers since it becomes simple to use by
using OpenCV-based Python. Face recognition technologies have a variety of applications in public protection,
entertainment, man-machine contact, and social networking, such as Facebook's automated tag recommendation on
images. It's also been seen in educational and non-educational institutes' attendance control, financial offices, voter
registration, and other areas [6], [7]
In this paper, we emphasize the important role of OpenCV in face detection and face recognition, what algorithm
can be used in OpenCV for face detection and face recognition, then state the OpenCV modules and explain OpenCV
based on Python and mention the applications for OpenCV are. Finally, we assessment and compared recent literature
reviews that use OpenCV to detect and recognize the human face in a variety of fields in order to improve human life.
The rest of this paper is organized as follows: in section 2, face detection is described. In section 3, face
recognition is explained. In section 4, OpenCV library and OpenCV algorithm are explained. In section 5 , Modules of
OpenCV are explained. In section 6, OpenCV based on Python is described. In section 7, the assessment of literature
reviews and comparison table are discussed. Section 8 concludes this paper.
2. Face Detection
Face detection has received much attention in recent years because of its applications in computer and human
interaction. Face detection is a subset of image processing. Image processing is primarily a technique for compressing,
improving, or extracting valuable information from images. Facial recognition technology can identify single or many
faces in a picture, removing unwanted background noise. A face identification algorithm must basically categorize
pictures into two groups based on whether or not they include a face. The face detection algorithm's goal is to
thoroughly examine the picture, identify the existence of faces in the image, and remove the background from the
image. Face detection mistakes are classified into two types: false negative and false positive. A false positive occurs
when a face is identified in a picture that does not include any faces. A false negative occurs when the algorithm rejects
the existence of anything in the picture. The detection rate is the ratio of the number of faces identified by humans to
the number of faces detected properly by the system. The detection rate of the face detection algorithm should be as
high as possible[1], [8].
3. Face Recognition
Facial recognition is the world's most advanced and quick biometric technology. It takes advantage of the most
visible human body component, the face, in a non-intrusive way. According to worldwide data, most individuals are
unaware of the face recognition process that is taking place on them, making it one of the least invasive procedures
with the least amount of delay. The facial recognition algorithm examines the many features of a face in the input
picture. This biometric has been extensively, and maybe exaggeratedly, lauded as a great method for identifying
possible dangers such as terrorists, scam artists, and so on, but it has yet to gain widespread acceptance in high-level
use. Biometric face recognition technology is expected to surpass fingerprint biometrics as the most common method of
user identification and authentication in the near future [8], [9], [10].
4. OpenCV Library
It is a massive open-source image processing, machine learning, and computer vision library. OpenCV is
compatible with a broad range of programming languages, including Python, C++, and Java. It will analyze
photographs and videos to recognize artifacts, faces, and even human handwriting. When paired with many other
libraries, like Numpy, a high-performance library for turning machines, achieve a good performance; that is, all
services that can be performed in Numpy can also be integrated with OpenCV.It is written based on C++ and has a C++
interface as its main interface, but it also has a less robust but still detailed older Language training. Both the latest
technologies and algorithms are visible in the C++ GUI. Python, Java, and MATLAB/OCTAVE bindings are available
[3]. Wrappers in a variety of programming languages have been created to promote broader acceptance. JavaScript
plugins for a variant of OpenCV functions are published as OpenCV.js in version 3.4, which can be used on web
platforms. The OpenCV project, which was officially unveiled in 1999, was originally Intel's research program to
support CPU-intensive applications [11].OpenCV is a popular platform for implementing face detection and
recognition algorithms. The following are some often used OpenCV algorithms.
87
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
88
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
4.3 EigenFaces
It is a method that employs PCA (Principal Component Analysis) to minimize dimensionality and find the
strongest vectors for distributing facial images onto existing facial spaces. The primary goal of PCA is to identify the
best vectors to explain the distribution of facial images in picture space into face space. According to the eigenvalue
distribution, m eigenvector is used to construct the principal component amount. Eigenvector and eigenvalue are
calculated from the qualified facial image's covariance matrix. The eigenvector is sorted by eigenvalue (high to low)
and M first eigenvectors are chosen to form the principal variable [1], [14].
4.4 FisherFaces
It is a face recognition system that several researchers have demonstrated to identify faces accurately. FisherFace is
a calculation model that combines the PCA (Principal Component Analysis) calculation model with Fisher's Linear
Discriminant (FLD). PCA is used to minimize input data in order to simplify and accelerate the FLD operation. On the
other hand, FLD is used to generate a distribution matrix to aid in classification and identification. A series of
FisherFaces is generated using the PCA and FLD calculation models. This facial recognition process consists of four
major steps: face identification, PCA estimation, calculation, and classification [15].
89
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
4.6 YOLO
Yolo is an abbreviation for (you only look once). It is the most recent real-time object detection system that uses a
single neural network to process the entire image [16]. This network splits the picture into sections and estimates the
bounding boxes and probabilities for each [17]. The estimated probabilities are used to weigh these bounding boxes.
The testing phase examines the whole picture, so the image's global meaning guides its predictions. Can detect objects
form videos or image [18] [19]. Fig. 5 shows the Yolo process.
90
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
5. Modules of OpenCV
5.1 Main Modules
Main modules are the main components of OpenCV and are included in the package versions by necessity. They
are called core modules since they include essential functions, including image recognition, filtering, and
transformation [8], [21].
91
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
into Python modules for ease of usage[3]. These two things offer great benefits: first, the code is as quick as C++ code
(as it is), and second, Python is simple to program in. The Python bindings for OpenCV function like this. The Python
implementation was built on top of the initial C++ code. Numpy's contribution helps here. Numpy is a highly structured
library that often offers Python-level statistical capabilities. It does things in a MATLAB-like fashion. Conversion to
Numpy arrays is done, and array processing is done on all the OpenCV structures. This is very good because whatever
functions it can do in Numpy, it can now combine with OpenCV, making you more efficient. SciPy, which also
supports NumPy, may be used along with this. So Python with OpenCV offers a good way to build out computer vision
projects [11] quickly.
92
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
planned goal points, including cost-effective deployment, simple installation, and real-time detection. Just 8-9 percent
of errors were discovered during tests of 150 samples, demonstrating the system's high precision and performance.
Patel et al. [23] suggested a method that senses whether or not the driver is asleep when operating a car or other big
vehicle, and if the driver is suspected sleepy, the system will alert the driver to wake up and stop driving. One of the
reasons for public road collisions is the driver's drowsiness when driving. It is necessary to develop an efficient
approach to predict somnolence as soon as the driver becomes drowsy. This may help to reduce the large number of
injuries that occur. This method would aid in the reduction of drivers' sleeping injuries. In the OpenCV setting, he used
real-time image processing with a vision device and the technique of facial expression and eye blinking.
93
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
of devices as well as the display of the location. An automated door surveillance system using raspberry pi python,
USB camera, and OpenCV is given for monitoring and security reasons. The system status database was created at a
certain point in time. The gadget is very cheap, simple to set up, and simple to use. The Attitude Tracking Algorithm is
extremely accurate and performs well.
[13] Face Keras VGG- module The results collected were rather similar to
2019 Recognition Face performance what was predicted. The efficiency gained
in Parallel depends on by simply running the program on a
Computer the number machine with more computing capacity and
of processors cores than a simple laptop was important.
[14] Recognition cascade successfully Gender, face, and age recognition was
2019 of the gender, LBP work but achieved
age, and face affected by
of the person LBPH mobile type,
face
coverage,
expressions
of face,
94
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
person pose
[15] criminal Haar-like 80% Since the computation period is very short,
2019 identification the proposed method will successfully
by face identify more than one face, which is helpful
recognition for rapidly looking for suspects.
automated
[16] Automated KNN 97% Prevent students from marking fake
2020 Attendance HaarCascade attendance for other students. It would also
System save faculty resources in universities by
LBPH eliminating the need for them to take
attendance of students who are present in
class, and it will be able to send monthly
attendance reports to students' parents by
email.
[17] Attendance HaarCascade 95% The results explicitly demonstrate that as the
2020 System in Paul – Viola. facial angle increases, face identification and
real-time recognition rate decreases.
[6] real-time Haar-cascade 90% The primary goal of this project is to
2020 system of camshift completely concentrate on the electronic
electronic voting mechanism and the protection of
voting every organization.
authorized by
face
recognition
[19] Face Mask Cascade between Since wearing a mask which becomes
2020 Detection to CNN 95.77%, mandatory before the Covid-19 crisis is
protect from 94.58% resolved, the implemented model can make
Covid-19 a significant contribution to the public health
care system.
[5] Autonomous Haar Cascade 83% Recognize human faces with some kind of
2020 Face camera and issue an alarm with a buzzer and
Detection an automatic-on light bulb that makes it
System from noticeable from a long distance.
Real-time
Video
Streaming
[20] Counting Cascade 90 to 100%. By installing cameras in the hallway, the
2020 students in model may be used to detect students who
classroom are skipping classes.
allocation
[24] A Face Haar hand gesture The developed system will function as a
2019 Recognition Cascade recognized is virtual assistant for a blind individual using
and Static 95.2% hand gestures and face recognition.
Hand Gesture LBPH
Facial
System for recognition is
the Blind 92%.
[11] Personal Cascade 90% Just 8-9 The proposed application helps companies
2018 Identifier Haar percent of calculate work attendance and detect cases
application errors were of fraud in work attendance compared to old
discovered work attendance monitoring methods.
after
analyzing
150 samples.
[25] door lock Attitude 95% According to the testing findings, the
2020 intelligence Tracking suggested system is more efficient, uses less
based on face Algorithm power, and is more cost-effective.
recognition (ATA)
[23] Drivers' EEG 90% This method would aid in the reduction of
2018 Somnolence ANN drivers' sleeping injuries. In the OpenCV
Detection setting, he used real-time image processing
method in with a vision device and the technique of
Real Time facial expression and eye blinking.
95
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
Based on Table 1, we compared the accuracy of techniques and classifiers of OpenCV used in a number of the
studies reviewed of face detection and face recognition in different areas of computer vision. From our observations of
the 20 reviewed studies (publications) (2018–2020) discussing the used methods of face detection and recognition in
the field of computer vision using OpenCV. It was found that OpenCV can be used in different fields like face
detection, recognition the faces, and Recognize facial expressions [26], [27]. Also, it was found that we can use
OpenCV in the security field like criminal identification [28]. Additionally, others used OpenCV to automate the
attendance of students or workers in institutions. At the same time, other researchers used OpenCV to reducing traffic
accidents on the roads.
8. Conclusion
Computer Vision is the subfield of Artificial Intelligence, where computers are trained to process the image and
extract the important features from the images or videos. Open Computer Vision (OpenCV), a python library written in
C++, provides various functionalities for computer vision applications. Applications of computer vision are object
detection, face recognition, medical diagnosis, etc. In this paper, we emphasize the important role of OpenCV in face
detection and face recognition. We illustrate the popular algorithms in OpenCV that are used for face detection and face
recognition. Then state the OpenCV modules and explain OpenCV based on Python and mention the applications for
OpenCV. Finally, we assessment and compared recent literature reviews that use OpenCV to detect and recognize the
human face in a variety of fields in order to improve human life.
Acknowledgement
The authors would like to thank the IT Department, Technical College of Informatics Akre, Duhok Polytechnic
University, Duhok, Kurdistan Region, Iraq and College of Engineering, Nawroz University, Duhok, Kurdistan Region,
Iraq.
References
[1] Jagtap, A. M., Kangale, V., Unune, K., & Gosavi, P. (2019, February). A Study of LBPH, Eigenface, Fisherface
and Haar-like features for Face recognition using OpenCV. In 2019 International Conference on Intelligent
Sustainable Systems (ICISS) (pp. 219-224). IEEE
[2] Sigut, J., Castro, M., Arnay, R., & Sigut, M. (2020). OpenCV basics: a mobile application to support the teaching
of computer vision concepts. IEEE Transactions on Education, 63(4), 328-335
[3] Adusumalli, H., Kalyani, D., Sri, R. K., Pratapteja, M., & Rao, P. P. (2021, February). Face Mask Detection Using
OpenCV. In 2021 Third International Conference on Intelligent Communication Technologies and Virtual Mobile
Networks (ICICV) (pp. 1304-1309). IEEE
[4] Mostafa, S. A., Mustapha, A., Gunasekaran, S. S., Ahmad, M. S., Mohammed, M. A., Parwekar, P., & Kadry, S.
(2021). An agent architecture for autonomous UAV flight control in object classification and recognition
missions. Soft Computing, 1-14
[5] Hoque, M. A., Islam, T., Ahmed, T., & Amin, A. (2020, March). Autonomous face detection system from real-
time video streaming for ensuring the intelligence security system. In 2020 6th International Conference on
Advanced Computing and Communication Systems (ICACCS) (pp. 261-265). IEEE
[6] Soomro, Z. A., Memon, T. D., Naz, F., & Ali, A. (2020, January). FPGA Based Real-Time Face Authorization
System for Electronic Voting System. In 2020 3rd International Conference on Computing, Mathematics and
Engineering Technologies (iCoMET) (pp. 1-6). IEEE
[7] Gupta, S. (2018, January). Facial emotion recognition in real-time and static images. In 2018 2nd international
conference on inventive systems and control (ICISC) (pp. 553-560). IEEE
[8] Dino, H., Abdulrazzaq, M. B., Zeebaree, S. R., Sallow, A. B., Zebari, R. R., Shukur, H. M., & Haji, L. M. (2020).
Facial expression recognition based on hybrid feature extraction techniques with different classifiers. TEST
Engineering & Management, 83, 22319-22329
[9] Kashinath, S. A., Mostafa, S. A., Mustapha, A., Mahdin, H., Lim, D., Mahmoud, M. A., ... & Yang, T. J. (2021).
Review of Data Fusion Methods for Real-Time and Multi-Sensor Traffic Flow Analysis. IEEE Access
[10] Abdulrazaq, M. B., Mahmood, M. R., Zeebaree, S. R., Abdulwahab, M. H., Zebari, R. R., & Sallow, A. B. (2021,
February). An analytical appraisal for supervised classifiers’ performance on facial expression recognition based
on relief-F feature selection. In Journal of Physics: Conference Series (Vol. 1804, No. 1, p. 012055). IOP
Publishing
[11] Sriratana, W., Mukma, S., Tammarugwattana, N., & Sirisantisamrid, K. (2018, July). Application of the OpenCV-
Python for Personal Identifier Statement. In 2018 International Conference on Engineering, Applied Sciences, and
Technology (ICEAST) (pp. 1-4). IEEE
[12] James, C., & Nettikadan, D. (2019, April). Student monitoring system for school bus using facial recognition.
In 2019 3rd International Conference on Trends in Electronics and Informatics (ICOEI) (pp. 659-663). IEEE
96
Hasan et al., Journal of Soft Computing and Data Mining Vol. 2 No. 1 (2021) p. 86-97
[13] Balachandran, B., Saad, K. F., Patel, K., & Mekhiel, N. (2019, December). Parallel Computer for Face
Recognition Using Artificial Intelligence. In 2019 14th International Conference on Computer Engineering and
Systems (ICCES) (pp. 158-162). IEEE
[14] Salihbašić, A., & Orehovački, T. (2019, May). Development of android application for gender, age and face
recognition using opencv. In 2019 42nd International Convention on Information and Communication
Technology, Electronics and Microelectronics (MIPRO) (pp. 1635-1640). IEEE
[15] Apoorva, P., Impana, H. C., Siri, S. L., Varshitha, M. R., & Ramesh, B. (2019, March). Automated criminal
identification by face recognition using open computer vision classifiers. In 2019 3rd International Conference on
Computing Methodologies and Communication (ICCMC) (pp. 775-778). IEEE
[16] Gupta, N., Sharma, P., Deep, V., & Shukla, V. K. (2020, June). Automated attendance system using OpenCV.
In 2020 8th International Conference on Reliability, Infocom Technologies and Optimization (Trends and Future
Directions)(ICRITO) (pp. 1226-1230). IEEE
[17] Srivastava, M., Kumar, A., Dixit, A., & Kumar, A. (2020, February). Real time attendance system using face
recognition technique. In 2020 International Conference on Power Electronics & IoT Applications in Renewable
Energy and its Control (PARC) (pp. 370-373). IEEE
[18] Sharma, V. K. (2019, May). Designing of Face Recognition System. In 2019 International Conference on
Intelligent Computing and Control Systems (ICCS) (pp. 459-461). IEEE
[19] Das, A., Ansari, M. W., & Basak, R. (2020, December). Covid-19 Face Mask Detection Using TensorFlow, Keras
and OpenCV. In 2020 IEEE 17th India Council International Conference (INDICON) (pp. 1-5). IEEE
[20] Mehariya, J., Gupta, C., Pai, N., Koul, S., & Gadakh, P. (2020, July). Counting Students using OpenCV and
Integration with Firebase for Classroom Allocation. In 2020 International Conference on Electronics and
Sustainable Communication Systems (ICESC) (pp. 624-629). IEEE
[21] Boyko, N., Basystiuk, O., & Shakhovska, N. (2018, August). Performance evaluation and comparison of software
for face recognition, based on dlib and opencv library. In 2018 IEEE Second International Conference on Data
Stream Mining & Processing (DSMP) (pp. 478-482). IEEE
[22] Alcantara, G. K. L., Evangelista, I. D. J., Malinao, J. V. B., Ong, O. B., Rivera, R. S. D., & Ambata, E. L. U.
(2018). Head detection and tracking using OpenCV. In 2018 IEEE 10th International Conference on Humanoid,
Nanotechnology, Information Technology, Communication and Control, Environment and Management
(HNICEM) (pp. 1-5). IEEE
[23] Patel, R., Patel, M., & Patel, J. (2018, April). Real Time Somnolence Detection System In OpenCV Environment
for Drivers. In 2018 Second International Conference on Inventive Communication and Computational
Technologies (ICICCT) (pp. 407-410). IEEE
[24] Sharma, S., & Jain, S. (2019, March). A static hand gesture and face recognition system for blind people. In 2019
6th International Conference on Signal Processing and Integrated Networks (SPIN) (pp. 534-539). IEEE.
[25] Zhu, Z., & Cheng, Y. (2020). Application of attitude tracking algorithm for face recognition based on OpenCV in
the intelligent door lock. Computer Communications, 154, 390-397
[26] Chandan, G., Jain, A., & Jain, H. (2018, July). Real time object detection and tracking using Deep Learning and
OpenCV. In 2018 international conference on inventive research in computing applications (ICIRCA) (pp. 1305-
1308). IEEE
[27] Khan, M., Chakraborty, S., Astya, R., & Khepra, S. (2019, October). Face Detection and Recognition Using
OpenCV. In 2019 International Conference on Computing, Communication, and Intelligent Systems
(ICCCIS) (pp. 116-119). IEEE
[28] Palekar, R. R., Parab, S. U., Parikh, D. P., & Kamble, V. N. (2017, April). Real time license plate detection using
openCV and tesseract. In 2017 international conference on communication and signal processing (ICCSP) (pp.
2111-2115). IEEE
97