#!/usr/bin/python

import pygame as pg
from operator import add
from simplecv.factory import Factory
from simplecv.display import Display
from simplecv.image_set import ImageSet

d = Display(flags=pg.FULLSCREEN)
#create video streams

cam = Factory.Kinect()
#initialize the camera
frames_to_blur = 4
frames = ImageSet()

depth = cam.getDepth().stretch(0, 200)
while True:
    new_depth = cam.getDepth().stretch(0, 200)
    img = cam.getImage()
    diff_1 = new_depth - depth
    diff_2 = depth - new_depth
    diff = diff_1 + diff_2
    img_filter = diff.binarize(0)

    motion_img = img - img_filter
    motion_img_open = motion_img.morph_open()

    frames.append(motion_img_open)
    if len(frames) > frames_to_blur:
        frames.pop(0)
示例#2
0
sudo apt-get install python-zbar


Then line up the item in the red box and left click the mouse to tell
the program to try and read the barcode
'''

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)

Then line up the item in the red box and left click the mouse to tell
the program to try and read the barcode
'''

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
#!/usr/bin/python

import time
import numpy as np
import pygame as pg
from simplecv.factory import Factory
from simplecv.display import Display

d = Display(flags = pg.FULLSCREEN)
#create video streams

cam = Factory.Kinect()
#initialize the camera

compositeframe = Factory.Image((640, 480))
#populate the compositeframe

offtime = 5.0
laststroke = time.time()

while not d.isDone():
    img = cam.getImage()
    imgscene = img.copy()

    depth = cam.getDepth()
    mindepth = np.min(depth.get_numpy())

    if mindepth < 180:
        depthbin = depth.binarize(np.min(depth.get_numpy()) + np.std(depth.get_numpy()) / 4).erode(3)
        #take the front 1/4 stdev of the depth map
#!/usr/bin/python


from operator import add
from simplecv.core.camera import Camera
from simplecv.display import Display
from simplecv.factory import Factory

cam = Camera()
display = Display((800,600))
counter = 0
# load the cascades
face_cascade = HaarCascade("face")
nose_cascade = HaarCascade("nose")
stache = Image("stache.png", sample=True) # load the stache
mask = stache.createAlphaMask() # load the stache mask
count = 0
while display.isNotDone():
    img = cam.getImage()
    img = img.scale(.5) #use a smaller image
    faces = img.find_haar_features(face_cascade) #find faces
    if( faces is not None ): # if we have a face
        faces = faces.sort_area() #get the biggest one
        face = faces[-1]
        myFace = face.crop() # get the face image
        noses = myFace.find_haar_features(nose_cascade) #find the nose
        if( noses is not None ):# if we have a nose
            noses = noses.sort_area()
            nose = noses[0] # get the biggest
            # these get the upper left corner of the face/nose with respect to original image
            xf = face.x -(face.get_width()/2)