Skip to content

Instantly share code, notes, and snippets.

@rishimukherjee
Created March 27, 2012 21:13
Show Gist options
  • Save rishimukherjee/2220293 to your computer and use it in GitHub Desktop.
Save rishimukherjee/2220293 to your computer and use it in GitHub Desktop.
Example of use of SimpleCV. This creates a face recognized password.
#!/usr/bin/python
import time
from SimpleCV import Color, Image, np, Camera
cam = Camera() #initialize the camera
quality = 400
minMatch = 0.3
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)
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
@samanta24
Copy link

how to get the facetrack-training.xml?

@johnfidel98
Copy link

how to get the facetrack-training.xml?

Copy link

ghost commented Jan 12, 2016

https://github.com/mmwanga/facetracking --> link for the facetrack-training.xml

@mrsid96
Copy link

mrsid96 commented Jan 26, 2017

/usr/local/lib/python2.7/dist-packages/SimpleCV/ImageClass.py:8456: VisibleDeprecationWarning: converting an array with ndim > 0 to an index will result in an error in the future
rhs.append((skp[idx[i]].pt[0], skp[idx[i]].pt[1]))
YOU ARE NOT THE ONE!!!
RUN AWAY OR POLICE WILL THROW YOU BEHIND THE BARS....:P

It gives the same result everytime, any tweaks ?

@SOAVI
Copy link

SOAVI commented Mar 15, 2017

i am getting a error
fatal python error=(pygame parachute) segmentation fault
what is it?

@SOAVI
Copy link

SOAVI commented Mar 15, 2017

how can i remove it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment