-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_verify.py
56 lines (35 loc) · 1.42 KB
/
image_verify.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import warnings
import face_recognition.api as face_recognition
import scipy
# Old Image Fxn
def old_image_src(src_old):
src_old_encodings = []
old_image = face_recognition.load_image_file(src_old)
encode_old_image = face_recognition.face_encodings(old_image)
if len(encode_old_image) == 1:
src_old_encodings.append(encode_old_image[0])
return src_old_encodings
# New Image Fxn
def new_image_src(src_new, src_old_encodings):
new_image = face_recognition.load_image_file(src_new)
# Scale down image
if new_image.shape[1] > 1600:
scale_factor = 1600.0 / new_image.shape[1]
with warnings.catch_warnings():
warnings.simplefilter("ignore")
new_image = scipy.misc.imresize(new_image, scale_factor)
encode_new_image = face_recognition.face_encodings(new_image)
if len(encode_new_image)==1:
for one_encode_new_image in encode_new_image:
result = face_recognition.compare_faces(src_old_encodings, one_encode_new_image)
print("Successful Image Matching") if True in result else print("Unsuccessful Image Matching !! ")
return result[0]
else:
return "0","No face Detected"
def onCreate(src_old, src_new):
src_old_encodings = old_image_src(src_old)
result= new_image_src(src_new, src_old_encodings)
return result
if __name__ == "__main__":
onCreate(sys.argv[1],sys.argv[2])