-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfacerecognition
More file actions
executable file
·79 lines (65 loc) · 1.8 KB
/
facerecognition
File metadata and controls
executable file
·79 lines (65 loc) · 1.8 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/local/bin/python
# IMPORTANT THE ABOVE SHOULD MATCH THE PATH TO PYTHON ON YOUR MACHINE
import faceDetection as tTest
import sys
import os
import crop
import cv2
from face_rec.recognize import EigenfaceRecon,FishRecon,EigenRecon
from face_rec.utils import make_array,judge
from PIL import Image
import matplotlib.pyplot as plt
import glob
import numpy as np
filepath = sys.argv[1]
rect = tTest.getRectangle(filepath)
contents = open('avgHW.csv','r').read()
H,W = contents.split(',')
H = int(H)
W = int(W)
centerY = (rect[3] + rect[1])/2
centerX = (rect[2] + rect[0])/2
# im = crop.cropp(filepath,rect)
# contents = open('avgHW.csv','r').read()
# H,W = contents.split(',')
# H = int(H)
# W = int(W)
# centerY = (rect[3] + rect[1])/2
# centerX = (rect[2] + rect[0])/2
im = crop.cropp(filepath,rect)
arr = np.asarray(im)
# plt.imshow(arr)
# plt.show()
################
########Use Fish
################
# recon = FishRecon('bin/phase2_fish_minsample/')
# best_idx,max_match = recon.recognize(arr.flatten())
# # print best_idx
# # print max_match
# if max_match > 15.5:
# print "This is : %r" % best_idx
# else:
# print "No match."
################
########Use Eigen
#################
# recon = EigenfaceRecon('bin/phase2_eigenfacial_minsample/')
# best_idx,max_match = recon.recognize(arr.flatten())
# print best_idx[:5]
# print max_match[:5]
# if max_match[0] < 10000:
# print "This is : %r" % best_idx[0]
# else:
# print "No match."
recon = FishRecon('bin/doug_last_minute/')
best_idx,max_match = recon.recognize(arr.flatten())
# print best_idx
# print max_match
with open('results_codejam.txt','a') as f:
if max_match > 15.5:
print "%s ---- is : %r" % (filepath, best_idx)
f.write("\n%s ---- is : %r\n" % (filepath, best_idx))
else:
print "No match for %s" % filepath
f.write("\nNo match for %s\n" % filepath)