Skip to content

Commit c8546ba

Browse files
committed
Changed the README file
1 parent aa56dcd commit c8546ba

File tree

6 files changed

+90
-0
lines changed

6 files changed

+90
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Face Detection
2+
3+
## Aim
4+
5+
The aim of the program given is to detect object of interest(face) in real time and to keep tracking of the same object. This is a simple example of how to detect face in Python.
6+
7+
8+
## Purpose
9+
10+
- The purpose is to Build A Real-Time Face Algorithm used to identify faces in an image or a real time video.
11+
- The algorithm uses edge or line detection features proposed by Viola and Jones in their research paper “Rapid Object Detection using a Boosted Cascade of Simple Features” published in 2001.
12+
13+
14+
## Short description of package/script
15+
16+
- Face Recognition is a technology in computer vision. In Face recognition / detection we locate and visualize the human faces in any digital image.
17+
- The __OpenCV GitHub repository__ has the models stored in XML files, and can be read with the OpenCV methods.
18+
- These include models for face detection, eye detection, upper body and lower body detection, license plate detection etc.
19+
- In this project, I applied face detection to some photos from Harry Potter using OpenCV with Python.
20+
21+
22+
## Workflow of the Project
23+
24+
![Professor Snape](./images/Flow_FaceDetection_OpenCV.jpg)
25+
26+
For the classier, we have used packages contain Haar cascade files. cv2.data.haarcascades
27+
28+
## Detailed explanation of script, if needed
29+
30+
If code is not explainable using comments, use this sections to explain your script
31+
32+
33+
## Setup instructions \& Execution
34+
35+
1. Make sure you have Python 3.7 and a text editor installed.
36+
2. Install the required packages using pip install -r requirements.txt.
37+
3. In the main directory Run `python3 face_detection.py` or `python face_detection.py`.
38+
4. Enter the path of the file.
39+
40+
41+
## Sample Test Cases
42+
43+
Some Results of the program:
44+
45+
![Harry Potter](./images/harry.png)
46+
47+
![Professor Snape](./images/snape.png)
48+
49+
50+
## Author(s)
51+
52+
Kushal Borkar
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
import cv2
3+
4+
# cascades: https://github.com/opencv/opencv/tree/master/data/haarcascades
5+
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
6+
7+
8+
def read_file(image_path):
9+
if os.path.isfile(image_path):
10+
img = cv2.imread(image_path)
11+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
12+
return True, img, gray
13+
14+
else:
15+
return False, False
16+
17+
18+
while(True):
19+
input_path = str(input("Enter the path of the file: "))
20+
val, img, gray = read_file(input_path)
21+
if val == True:
22+
break
23+
24+
rects = face_cascade.detectMultiScale(gray, scaleFactor=1.05,
25+
minNeighbors=10, minSize=(30, 30),
26+
flags=cv2.CASCADE_SCALE_IMAGE)
27+
28+
29+
# loop over the bounding boxes
30+
for (x, y, w, h) in rects:
31+
# draw the face bounding box on the image
32+
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
33+
34+
35+
# show the output image
36+
cv2.imshow("Image", img)
37+
cv2.waitKey(0)
13.6 KB
Loading
945 KB
Loading
198 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
opencv_python==4.5.1.48

0 commit comments

Comments
 (0)