from SimpleCV import Camera, Display, Image
from time import sleep

myCamera = Camera(prop_set={'width': 320, 'height': 240})
myDisplay = Display(resolution=(320, 240))
stache = Image("mustache-small.bmp")
stacheMask = stache.createBinaryMask(color1=(0, 0, 0), color2=(254, 254, 254))
stacheMask = stacheMask.invert()
while not myDisplay.isDone():
    frame = myCamera.getImage()
    faces = frame.findHaarFeatures('face')
    if faces:
        for face in faces:
            print "Face at: " + str(face.coordinates())
            myFace = face.crop()
            noses = myFace.findHaarFeatures('nose')
            if noses:
                nose = noses.sortArea()[-1]
                print "Nose at: " + str(nose.coordinates())
                xmust = face.points[0][0] + nose.x - (stache.width / 2)
                ymust = face.points[0][1] + nose.y + (stache.height / 3)
                frame = frame.blit(stache, pos=(xmust, ymust), mask=stacheMask)
                frame.save(myDisplay)
    else:
        print "No faces detected."
    sleep(1)
示例#2
0
from SimpleCV import Image, Camera, Display
from time import sleep

camera = Camera(prop_set={'width':320, 'height':240})
display = Display(resolution=(320, 240))

mustacheImage = Image("/Users/jharms/Desktop/Mustache.jpg")
mustacheImage = mustacheImage.resize(w=120, h=80)
stacheMask = mustacheImage.createBinaryMask(color1=(10,10,10), color2=(255,255,255))
stacheMask = stacheMask.invert()
#i.save(myDisplay)

def mustachify(frame):
    faces = None
    print frame.listHaarFeatures()
    faces = frame.findHaarFeatures('face')
    if faces:
        for face in faces:
            print "Gesicht bei " + str(face.coordinates())
            frame = frame.blit(mustacheImage, pos=face.coordinates(), mask=stacheMask)
    return frame
    
while not display.isDone():
    frame = camera.getImage()
    frame = mustachify(frame)
    frame.save(display)
    sleep(.1)
from time import sleep, time
from SimpleCV import Camera, Image, Display
import RPi.GPIO as GPIO

myCamera = Camera(prop_set={'width':320, 'height': 240})
myDisplay = Display(resolution=(320, 240))
stache = Image("mustache.png")
stacheMask = stache.createBinaryMask(color1=(0,0,0), color2=(254,254,254))
stacheMask = stacheMask.invert()

GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.IN)

def mustachify(frame):
   faces = frame.findHaarFeatures('face')
   if faces:
      for face in faces:
         print "Face at: " + str(face.coordinates())
         myFace = face.crop()
         noses = myFace.findHaarFeatures('nose')
         if noses:
            nose = noses.sortArea()[-1]
            print "Nose at: " + str(nose.coordinates())
            xmust = face.points[0][0] + nose.x - (stache.width/2)
            ymust = face.points[0][1] + nose.y + (stache.height/3)
         else:
            return frame
      frame = frame.blit(stache, pos=(xmust, ymust), mask=stacheMask)
      return frame
   else:
      return frame
示例#4
0
from SimpleCV import Image,Color
img = Image("lena.jpg")
mask = img.createBinaryMask(color1=(130,125,100),color2=Color.BLACK)
mask = mask.morphClose()
result = img - mask.invert()
result.show()