Repository: aydinnyunus/FaceRecognitionSecurity
Branch: master
Commit: 8702fdf632c3
Files: 3
Total size: 4.3 KB
Directory structure:
gitextract_0a4ayqi2/
├── Protect.py
├── README.md
└── Take Photo.py
================================================
FILE CONTENTS
================================================
================================================
FILE: Protect.py
================================================
import face_recognition
import cv2
import numpy as np
import pyautogui
from selenium import webdriver
import time
import os
gmail = "ENTER GMAIL HERE"
password = "ENTER PASSWORD HERE"
video_capture = cv2.VideoCapture(0)
root_image = face_recognition.load_image_file("YOUR PHOTO PATH")
root_encoding = face_recognition.face_encodings(root_image)[0]
known_face_encodings = [
root_encoding,
]
known_face_names = [
"YOUR NAME",
]
while True:
ret, frame = video_capture.read()
rgb_frame = frame[:, :, ::-1]
face_locations = face_recognition.face_locations(rgb_frame)
face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
name = "Unknown"
for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
# See if the face is a match for the known face(s)
matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
face_distances = face_recognition.face_distance(known_face_encodings, face_encoding)
best_match_index = np.argmin(face_distances)
if matches[best_match_index]:
name = known_face_names[best_match_index]
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
if name != "YOUR NAME":
driver = webdriver.Chrome(executable_path="CHROME DRIVER PATH")
driver.get("https://www.google.com/android/find")
time.sleep(2)
pyautogui.typewrite(gmail)
pyautogui.press("enter")
time.sleep(2)
pyautogui.typewrite(password)
pyautogui.press("enter")
time.sleep(5)
pyautogui.click(x=85,y=231)
time.sleep(2)
pyautogui.click(x=200,y=495)
pyautogui.hotkey('ctrlleft', 'altleft', 'l')
else:
print("Welcome BOSS")
os.system("gnome-terminal")
# Display the resulting image
cv2.imshow('Video', frame)
# Release handle to the webcam
video_capture.release()
cv2.destroyAllWindows()
================================================
FILE: README.md
================================================
# FaceRecognitionSecurity
Protect your Computer against strangers ! If foreigners want to log in to your computer, ring your phone and lock the computer screen automatically.
## Features
Face Recognition in Live Camera

## Installation
### Requirements
• Python 3.3+ or Python 2.7
• macOS or Linux (Windows not officially supported, but might work)
• For Install "face_recognition and dlib" : [Click Here!](https://github.com/ageitgey/face_recognition)
• Chrome Driver : https://chromedriver.chromium.org/downloads
## Usage

• Change GMAIL,PASSWORD,DRIVER LOCATION and PHOTO LOCATION in Protect.py
```
If you don't have a photo run 'python Take Photo.py' and Press SPACE for Take Photo.
Else run 'python Protect.py'
```
• If Camera Detect Your Face Open a new Terminal.Otherwise The Phone Will Ring Even If It is Silent.
• Connect to the Google Android Find My Phone and Click the Ring the Phone Button and Lock the Screen.

## Contact
[
](https://linkedin.com/in/yunus-ayd%C4%B1n-b9b01a18a/) [
](https://github.com/aydinnyunus/WhatsappBOT) [
](https://instagram.com/aydinyunus_/) [
](https://twitter.com/aydinnyunuss)
================================================
FILE: Take Photo.py
================================================
import cv2
cam = cv2.VideoCapture(-1)
cv2.namedWindow("test")
img_counter = 0
while True:
ret, frame = cam.read()
cv2.imshow("test", frame)
if not ret:
break
k = cv2.waitKey(1)
if k%256 == 27:
# ESC pressed
print("Escape hit, closing...")
break
elif k%256 == 32:
# SPACE pressed
img_name = "opencv_frame_{}.png".format(img_counter)
cv2.imwrite(img_name, frame)
print("{} written!".format(img_name))
img_counter += 1
cam.release()
cv2.destroyAllWindows()