-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_faces.py
41 lines (31 loc) · 1.02 KB
/
set_faces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import face_recognition
import requests
import json
from auth import db
from identify import findface
import pickle
# load image
load_image = face_recognition.load_image_file('./img/groups/Dipanshu.jpeg')
# find face locations
face_locations = face_recognition.face_locations(load_image)
# get face encodings
face_encoding = face_recognition.face_encodings(load_image, face_locations)
# search for exsisting faces
exsisting_face_name = findface.findFace(face_locations, face_encoding)
if (exsisting_face_name):
print("FACE FOUND")
print(f'Face matches with {exsisting_face_name}')
else:
print("FACE NOT FOUND")
# input name
name = input('Enter the name of person: ')
# convert name into BLOB string
face_pickled_data = pickle.dumps(face_encoding)
# setup database connection
mydb = db.databaseConnection()
mycursor = mydb.cursor()
# mysql query
sql = "INSERT INTO face_recog (image,name) VALUES (%s, %s)"
val = (face_pickled_data, name)
mycursor.execute(sql, val)
mydb.commit()