-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcampass.py
More file actions
72 lines (66 loc) · 2.35 KB
/
campass.py
File metadata and controls
72 lines (66 loc) · 2.35 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
#!/usr/bin/python
"""
copyright: Rishi Mukherjee
"""
import time
from SimpleCV import Color, Image, np, Camera
from SimpleCV.Display import Display
import sys
cam = Camera() #initialize the camera
quality = 400
minMatch = 0.1
try:
password = Image("password.jpg")
except:
password = None
mode = "unsaved"
saved = False
minDist = 0.25
while True:
image = cam.getImage().scale(320, 240) # get image, scale to speed things up
faces = image.findHaarFeatures("facetrack-training.xml") # load in trained face file
if faces:
if not password:
faces.draw()
face = faces[-1]
password = face.crop().save("password.jpg")
break
else:
faces.draw()
face = faces[-1]
template = face.crop()
template.save("passwordmatch.jpg")
keypoints = password.findKeypointMatch(template,quality,minDist,minMatch)
password.drawKeypointMatches(template).save("password2.jpg")
if keypoints:
print "YOU ARE THE ONE!!! CONGRATS"
question = raw_input("WOULD YOU LIKE TO CHANGE YOUR FACE PASSWORD? Y/N: ").strip()
if question == "Y":
image = cam.getImage().scale(320, 240)
faces = image.findHaarFeatures("facetrack-training.xml")
tryit = 1
while not tryit == 10 or not faces:
image = cam.getImage().scale(320, 240)
faces = image.findHaarFeatures("facetrack-training.xml")
tryit += 1
if not faces:
"CANNOT FIND ANY FACE, QUITING"
break
else:
faces.draw()
face = faces[-1]
password = face.crop().save("password.jpg")
face.crop().show()
print "SUCCESSFULLY SAVED"
print "QUITING"
time.sleep(1)
break
else:
print "OK..."
break
else:
print "YOU ARE NOT THE ONE!!!"
print "RUN AWAY OR POLICE WILL THROW YOU BEHIND THE BARS....:P"
break
else:
break