FaceRecognition icon indicating copy to clipboard operation
FaceRecognition copied to clipboard

missing face recognition with python & openCV

Open meghal2110 opened this issue 2 years ago • 3 comments

meghal2110 avatar Oct 07 '22 14:10 meghal2110

I want to work in this issue @riya-17

meghal2110 avatar Oct 07 '22 14:10 meghal2110

i want work in this isssue

hamma741 avatar Apr 29 '23 14:04 hamma741

Facial recognition is a popular computer vision application, and OpenCV is a widely-used library for image and video processing in Python. In this tutorial, I will provide a brief overview of how to perform facial recognition using Python and OpenCV.

Here are the steps to perform facial recognition using Python and OpenCV:

Install OpenCV: You can install OpenCV using pip or conda. For example, using pip, you can type pip install opencv-python in your command prompt or terminal.

Load the Haar Cascade Classifier: The Haar Cascade Classifier is a pre-trained classifier that can be used to detect faces in images. You can load this classifier using the cv2.CascadeClassifier function in OpenCV.

Load the input image: You can load the input image using the cv2.imread function in OpenCV.

Convert the input image to grayscale: Convert the input image to grayscale using the cv2.cvtColor function in OpenCV.

Detect faces in the input image: You can detect faces in the input image using the detectMultiScale function of the Haar Cascade Classifier.

Draw rectangles around the detected faces: Once you have detected the faces, you can draw rectangles around them using the cv2.rectangle function in OpenCV.

Display the output image: Finally, you can display the output image using the cv2.imshow function in OpenCV.

import cv2

Load the Haar Cascade Classifier

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

Load the input image

img = cv2.imread('input_image.jpg')

Convert the input image to grayscale

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Detect faces in the input image

faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5)

Draw rectangles around the detected faces

for (x, y, w, h) in faces: cv2.rectangle(img, (x, y), (x+w, y+h), (0, 255, 0), 2)

Display the output image

cv2.imshow('img', img) cv2.waitKey()

Note: Make sure to replace 'haarcascade_frontalface_default.xml' with the correct path to the Haar Cascade Classifier on your system, and 'input_image.jpg' with the path to your input image.

This is just a basic example of how to perform facial recognition using Python and OpenCV. There are many advanced techniques and algorithms available to improve the accuracy and performance of facial recognition systems

hamma741 avatar Apr 29 '23 14:04 hamma741