Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing face recognition with python & openCV #53

Open
meghal2110 opened this issue Oct 7, 2022 · 3 comments
Open

missing face recognition with python & openCV #53

meghal2110 opened this issue Oct 7, 2022 · 3 comments

Comments

@meghal2110
Copy link

No description provided.

@meghal2110
Copy link
Author

I want to work in this issue @riya-17

@MohamedBenhammouda
Copy link

i want work in this isssue

@MohamedBenhammouda
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants