Face Detection in 2 Minutes using OpenCV and Python with SourceCode

Publié le: 19 juin 2020
sur la chaîne: Sanket Ghodake
91
4

In this quick tutorial I explain how you can detect faces in images as well as videos using Haar Cascades in OpenCV and Python. Face detection is the first step for doing face recognition.

GitHub Link:https://github.com/SankeGhodake/Face-...

If you having any problem then contact me on:
sanketghodake2797@gmail.com
#machinelearning #python #facedetection #opencv

First of all make sure you have OpenCV installed. You can install it using pip:
pip install opencv-python

Face detection using Haar cascades is a machine learning based approach where a cascade function is trained with a set of input data. OpenCV already contains many pre-trained classifiers for face, eyes, smiles, etc.. Today we will be using the face classifier. You can experiment with other classifiers as well.
You need to download the trained classifier XML file (haarcascade_frontalface_default.xml), which is available in OpenCv’s GitHub repository. Save it to your working location.

A few things to note:

The detection works only on grayscale images. So it is important to convert the color image to grayscale. (line 8)
detectMultiScale function (line 10) is used to detect the faces. It takes 3 arguments — the input image, scaleFactor and minNeighbours. scaleFactor specifies how much the image size is reduced with each scale. minNeighbours specifies how many neighbors each candidate rectangle should have to retain it. You can read about it in detail here. You may have to tweak these values to get the best results.
faces contains a list of coordinates for the rectangular regions where faces were found. We use these coordinates to draw the rectangles in our image.


Sur cette page du site, vous pouvez voir la vidéo en ligne Face Detection in 2 Minutes using OpenCV and Python with SourceCode durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Sanket Ghodake 19 juin 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 91 fois et il a aimé 4 téléspectateurs. Bon visionnage!