Skip to content

Commit 0e55731

Browse files
* Added Face Detection * README.md Updatedx1 * README.md Updatedx2 * README.md Updatedx3 * Face Detection Successfully Created
1 parent 29228bc commit 0e55731

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

Face_Detection/Protect.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import face_recognition
2+
import cv2
3+
import numpy as qt
4+
import pyautogui
5+
from selenium import webdriver
6+
import time
7+
import os
8+
9+
10+
gmail = "ENTER GMAIL HERE"
11+
password = "ENTER PASSWORD HERE"
12+
13+
video_capture = cv2.VideoCapture(0)
14+
15+
root_image = face_recognition.load_image_file("YOUR PHOTO PATH")
16+
root_encoding = face_recognition.face_encodings(root_image)[0]
17+
18+
19+
known_face_encodings = [
20+
root_encoding,
21+
]
22+
known_face_names = [
23+
"YOUR NAME",
24+
]
25+
26+
while True:
27+
ret, frame = video_capture.read()
28+
29+
rgb_frame = frame[:, :, ::-1]
30+
31+
face_locations = face_recognition.face_locations(rgb_frame)
32+
face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
33+
name = "Unknown"
34+
35+
for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
36+
# See if the face is a match for the known face(s)
37+
matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
38+
39+
face_distances = face_recognition.face_distance(known_face_encodings, face_encoding)
40+
best_match_index = qt.argmin(face_distances)
41+
if matches[best_match_index]:
42+
name = known_face_names[best_match_index]
43+
44+
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
45+
46+
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
47+
font = cv2.FONT_HERSHEY_DUPLEX
48+
cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
49+
if name != "YOUR NAME":
50+
driver = webdriver.Chrome(executable_path="CHROME DRIVER PATH")
51+
driver.get("https://www.google.com/android/find")
52+
time.sleep(2)
53+
pyautogui.typewrite(gmail)
54+
pyautogui.press("enter")
55+
time.sleep(2)
56+
pyautogui.typewrite(password)
57+
pyautogui.press("enter")
58+
time.sleep(5)
59+
pyautogui.click(x=85,y=231)
60+
time.sleep(2)
61+
pyautogui.click(x=200,y=495)
62+
pyautogui.hotkey('ctrlleft', 'altleft', 'l')
63+
64+
else:
65+
print("Welcome BOSS")
66+
os.system("gnome-terminal")
67+
68+
# Display the resulting image
69+
cv2.imshow('Video', frame)
70+
71+
72+
# Release handle to the webcam
73+
video_capture.release()
74+
cv2.destroyAllWindows()

Face_Detection/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# FaceRecognitionSecurity
2+
Protect your Computer against strangers ! If foreigners want to log in to your computer, ring your phone and lock the computer screen automatically.
3+
## Features
4+
5+
Face Recognition in Live Camera
6+
7+
8+
## Installation
9+
### Requirements
10+
• Python 3.3+ or Python 2.7
11+
12+
• macOS or Linux (Windows not officially supported, but might work)
13+
14+
• For Install "face_recognition and dlib"
15+
16+
• Chrome Driver : https://chromedriver.chromium.org/downloads
17+
18+
## Usage
19+
![github-small](obama.png)
20+
21+
• Change GMAIL,PASSWORD,DRIVER LOCATION and PHOTO LOCATION in Protect.py
22+
23+
```
24+
If you don't have a photo run 'python Take Photo.py' and Press SPACE for Take Photo.
25+
Else run 'python Protect.py'
26+
```
27+
28+
• If Camera Detect Your Face Open a new Terminal.Otherwise The Phone Will Ring Even If It is Silent.
29+
30+
• Connect to the Google Android Find My Phone and Click the Ring the Phone Button and Lock the Screen.
31+
32+
33+
34+
35+

Face_Detection/Take Photo.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import cv2
2+
3+
cam = cv2.VideoCapture(-1)
4+
5+
cv2.namedWindow("test")
6+
7+
img_counter = 0
8+
9+
while True:
10+
ret, frame = cam.read()
11+
cv2.imshow("test", frame)
12+
if not ret:
13+
break
14+
k = cv2.waitKey(1)
15+
16+
if k%256 == 27:
17+
# ESC pressed
18+
print("Escape hit, closing...")
19+
break
20+
elif k%256 == 32:
21+
# SPACE pressed
22+
img_name = "opencv_frame_{}.png".format(img_counter)
23+
cv2.imwrite(img_name, frame)
24+
print("{} written!".format(img_name))
25+
img_counter += 1
26+
27+
cam.release()
28+
29+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)