Skip to content

Instantly share code, notes, and snippets.

@gustavopinto
Last active March 9, 2021 00:31
Show Gist options
  • Save gustavopinto/4685584 to your computer and use it in GitHub Desktop.
Save gustavopinto/4685584 to your computer and use it in GitHub Desktop.
mustacheinator.py
from SimpleCV import Camera, Display, Image
cam = Camera()
disp = Display((800, 600))
stache = Image("mustache.png")
mask = stache.invert()
while disp.isNotDone():
img = cam.getImage()
faces = img.findHaarFeatures('face')
if faces is not None:
face = faces.sortArea()[-1]
face.draw()
myface = face.crop()
noses = myface.findHaarFeatures('nose')
if noses is not None:
nose = noses.sortArea()[-1]
x = face.points[0][0] + nose.x - 100 #cabalistic number
y = face.points[0][1] + nose.y + 10
img = img.blit(stache, pos=(x, y), mask=mask)
img.save(disp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment