Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8781335

Browse files
Merge pull request avinashkranjan#1161 from naazkakria/master
Improvised face detection code added
2 parents d573698 + 5b0193b commit 8781335

File tree

3 files changed

+24400
-0
lines changed

3 files changed

+24400
-0
lines changed

‎face_detection/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# FACE DETECTION
2+
3+
[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)
4+
5+
This project is to create using python , openCv through which we can check weather we are able to detect face or not.
6+
7+
## Usage
8+
* we can check weather we are able to detect face or not
9+
10+
11+
## Output :smiley:
12+
<img width="528" alt="figure" src="https://github.com/naazkakria/face_recognition_/blob/main/image_detected.jpeg">
13+
14+
## Authors
15+
Written by [Naaz](https://github.com/naazkakria)
16+
17+

‎face_detection/face_detect.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import cv2
2+
cap=cv2.VideoCapture(0)
3+
face_cascade =cv2.CascadeClassifier("haarcascade_frontalface_alt.xml")
4+
5+
while True:
6+
## capture camera frame, and ret store true and false
7+
r, frame= cap.read()
8+
gray_frame =cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
9+
10+
if r==False:
11+
continue
12+
faces=face_cascade.detectMultiScale(gray_frame,1.3,5)
13+
14+
## """ The first argument is the image, the second is the
15+
## scalefactor (how much the image size will be reduced at each image scale),
16+
## and the third is the minNeighbors (how many neighbors each rectangle should have)"""
17+
18+
for(x,y,w,h) in faces:
19+
cv2.rectangle(frame,(x,y),(x+w,y+h),(255,125,0),2)## color and width
20+
cv2.putText(frame,"DETECTED",(x,y-10),cv2.FONT_HERSHEY_SIMPLEX,1,(100,125,255),1,cv2.LINE_AA)
21+
cv2.imshow("video frame",frame)
22+
key_pressed =cv2.waitKey(1) & 0xFF
23+
24+
## """cv2.waitKey() returns a 32 Bit integer value (might be dependent on the platform).
25+
## The key input is in ASCII which is an 8 Bit integer value. So you only care
26+
## about these 8 bits and want all other bits to be 0. This you can achieve with:0xFF"""
27+
28+
### ord converts characters in unicode
29+
if key_pressed ==ord('n'):
30+
break
31+
32+
cap.release()
33+
cv2.destroyAllWindows()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /