# # Released under the BSD license. See LICENSE file for details. """ This program basically does face detection an blurs the face out. """ print __doc__ from simplecv import Camera, Display, HaarCascade # Initialize the camera cam = Camera() # Create the display to show the image display = Display() # Haar Cascade face detection, only faces haarcascade = HaarCascade("face") # Loop forever while display.isNotDone(): # Get image, flip it so it looks mirrored, scale to speed things up img = cam.getImage().flip_horizontal().scale(0.5) # Load in trained face file faces = img.find_haar_features(haarcascade) # Pixelize the detected face if faces: bb = faces[-1].get_bounding_box() img = img.pixelize(10, region=(bb[0], bb[1], bb[2], bb[3])) # Display the image img.save(display)
import time import csv from simplecv import Color, ColorCurve, Camera, Image, pg, np, cv from simplecv.display import Display cam = Camera() display = Display((800,600)) data = "None" mydict = dict() myfile = "barcode-list.csv" while display.isNotDone(): display.checkEvents()#check for mouse clicks img = cam.getImage() img.draw_rectangle(img.width/4,img.height/4,img.width/2,img.height/2,color=Color.RED,width=3) if display.mouseLeft: # click the mouse to read img.draw_text("reading barcode... wait",10,10) img.save(display) barcode = img.find_barcode() if barcode: # if we have a barcode data = str(barcode.data) print data if mydict.has_key(data): mydict[data] = mydict[data] + 1 else: mydict[data] = 1 img.draw_text("Click to scan.",10,10,color=Color.RED) myItem = "Last item scanned: " + data img.draw_text(myItem,10,30)
print __doc__ import time import csv from simplecv import Color, ColorCurve, Camera, Image, pg, np, cv from simplecv.display import Display cam = Camera() display = Display((800, 600)) data = "None" mydict = dict() myfile = "barcode-list.csv" while display.isNotDone(): display.checkEvents() #check for mouse clicks img = cam.getImage() img.draw_rectangle(img.width / 4, img.height / 4, img.width / 2, img.height / 2, color=Color.RED, width=3) if display.mouseLeft: # click the mouse to read img.draw_text("reading barcode... wait", 10, 10) img.save(display) barcode = img.find_barcode() if barcode: # if we have a barcode data = str(barcode.data) print data if mydict.has_key(data): mydict[data] = mydict[data] + 1
from simplecv import Camera, Display, HaarCascade, Image #initialize the camera cam = Camera() # Create the display to show the image display = Display() # Load the new face image troll_face = Image('troll_face.png', sample=True) # Haar Cascade face detection, only faces haarcascade = HaarCascade("face") # Loop forever while display.isNotDone(): # Get image, flip it so it looks mirrored, scale to speed things up img = cam.getImage().flip_horizontal().scale(0.5) # load in trained face file faces = img.find_haar_features(haarcascade) # If there were faces found do something if faces: face = faces[-1] # Load the image to super impose and scale it correctly troll = troll_face.scale(face.get_height(), face.get_width()) mymask = troll.invert() # Super impose the new face on the existing face img = img.blit(troll, face.top_left_corner(), alpha_mask=mymask) # Display the image img.save(display)