In this post, you'll learn how to build a face detection program using Python for yourself in less than 3 minutes.
Originally published by Sabina Pokhrel at https://towardsdatascience.com
Face detection is one of the most common applications of Artificial Intelligence. From camera applications in smartphones to Facebook’s tag suggestions, the use of face detection in applications is increasing every single day.
Face detection is the ability of a computer program to identify and locate human faces in a digital image.
With the increasing demand for face detection feature in applications, everyone is looking to use face detection in their application so that they are not left behind in the race.
In this post, I will teach you how to build a face detection program for yourself in less than 3 minutes.You will need to install the following python libraries if it is not already installed:
Here is the code to import the required python libraries, read an image from storage and display it.
# import libraries import cv2 import matplotlib.pyplot as plt import cvlib as cvimage_path = 'couple-4445670_640.jpg' im = cv2.imread(image_path) plt.imshow(im)
The code to detect faces in the loaded image, draw a bounding box around the detected faces and display the final image with detected faces is as follows.
faces, confidences = cv.detect_face(im)# loop through detected faces and add bounding box for face in faces: (startX,startY) = face,face (endX,endY) = face,face # draw rectangle over face cv2.rectangle(im, (startX,startY), (endX,endY), (0,255,0), 2)# display output plt.imshow(im)
Result of Face Detection on couple image
You have your face detection program ready. It is that simple!
To know more about cvlib library, you can visit the link
Thanks for reading ❤
If you liked this post, share it with all of your programming buddies!
Python has been the go-to choice for Machine Learning, Data Science and Artificial Intelligence developers for a long time. Python libraries for modern machine learning models & projects: TensorFlow; Numpy; Scipy; Scikit-learn; Theano; Keras; PyTorch; Pandas; Matplotlib; ...
Complete hands-on Machine Learning tutorial with Data Science, Tensorflow, Artificial Intelligence, and Neural Networks. Introducing Tensorflow, Using Tensorflow, Introducing Keras, Using Keras, Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), Learning Deep Learning, Machine Learning with Neural Networks, Deep Learning Tutorial with Python
What is Artificial Intelligence (AI)? AI is the ability of a machine to think like human, learn and perform tasks like a human. Know the future of AI, Examples of AI and who provides the course of Artificial Intelligence?