Exemplo n.º 1
0
#!/usr/bin/python

import time, webbrowser
from operator import add
from SimpleCV import Color, ColorCurve, Kinect, Image, pg, np
from SimpleCV.Display import Display

d = Display()
#create video streams

cam = Kinect()
#initialize the camera

compositeframe = 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.getNumpy())

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

        img = img.crop(0,25, 605, 455).scale(640,480)
Exemplo n.º 2
0
#!/usr/bin/python

from SimpleCV import Kinect, Image, pg, np, time
from SimpleCV.Display import Display

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

cam = Kinect()
#initialize the camera

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.morphOpen()
   motion_img_open.show()
   depth = new_depth
Exemplo n.º 3
0
#!/usr/bin/python

from SimpleCV import Kinect, Image, pg, np, time
from SimpleCV.Display import Display

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

cam = Kinect()
#initialize the camera

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.morphOpen()
    motion_img_open.show()
    depth = new_depth
Exemplo n.º 4
0
from SimpleCV import Kinect

# Initialize the Kinect
kin = Kinect()
# Initialize the display
display = kin.getDepth().show()
# Run in a continuous loop forever
while (True):
    # Snaps a picture, and returns the grayscale depth map
    depth = kin.getDepth()
    # Show the actual image on the screen
    depth.save(display)
Exemplo n.º 5
0
    def __init__(self, disable=False):
        self.__dict__ = self.__shared_state
        #ActiveState "Borg" Singleton replacement design
        if self.initialized:
            return  #successive calls to SimpleSeer simply return the borg'd object
        if disable:
            self.initialized = True
            self.disabled = True
            return


        #read config file
        self.config = Session()

        self.cameras = []
       
        for camera in self.config.cameras:
            camerainfo = camera.copy()
            if camerainfo.has_key('virtual'):
                self.cameras.append(VirtualCamera(camerainfo['source'], camerainfo['virtual']))
            elif camerainfo.has_key('directory'):
                self.cameras.append(util.DirectoryCamera(camerainfo['directory']))
            elif camerainfo.has_key('kinect'):
                k = Kinect()
                k._usedepth = 0
                k._usematrix = 0
                if camerainfo["kinect"] == "depth":
                    k._usedepth = 1
                elif camerainfo["kinect"] == "matrix":
                    k._usematrix = 1
                
                self.cameras.append(k)
            else:
                id = camerainfo['id']
                del camerainfo['id']
                del camerainfo['name']
                if camerainfo.has_key('crop'):
                    del camerainfo['crop']
                self.cameras.append(Camera(id, camerainfo))
        #log initialized camera X
        
        
        self.reloadInspections() #initialize inspections so they get saved to redis
         
        util.load_plugins()
        self.lastframes = []
        self.framecount = 0
        
        #log display started
        self.initialized = True

        if self.config.arduino:
          self.controls = Controls(self.config.arduino, self)
        
        
        super(SimpleSeer, self).__init__()
        self.daemon = True
        self.capture()
        #~ Inspection.inspect()
        #self.update()
        self.connection_file = None
        if self.config.auto_start:
            self.start()
Exemplo n.º 6
0
from SimpleCV import Kinect
import time
kin = Kinect()
img = kin.getImage()
img.show()
time.sleep(5)
from SimpleCV import Kinect, Display
import time

# Initialize the Kinect
kin = Kinect()

# Initialize the display
disp = Display((640,480))

# This should be adjusted to set how many pixels
# represent an inch in the system's environment
pixelsToInches = 6

while not disp.isDone():
    img = kin.getDepth()
    blobs = img.binarize().findBlobs()
    if blobs:
        img.drawText(str(blobs[-1].height() / pixelsToInches) + " inches", 10, 10)
    img.save(disp)
    time.sleep(1)
from SimpleCV import Kinect, Display
import time

# Initialize the Kinect
kin = Kinect()

# Initialize the display
disp = Display((640, 480))

# This should be adjusted to set how many pixels
# represent an inch in the system's environment
pixelsToInches = 6

while not disp.isDone():
    img = kin.getDepth()
    blobs = img.binarize().findBlobs()
    if blobs:
        img.drawText(
            str(blobs[-1].height() / pixelsToInches) + " inches", 10, 10)
    img.save(disp)
    time.sleep(1)
#!/usr/bin/python

from SimpleCV import Kinect, Image, pg, np, time
from SimpleCV.Display import Display


d = Display()
#create video streams

cam = Kinect()
#initialize the camera

# porto a bianco tutte le sfumature in depth da 200 a 2048
depth = cam.getDepth()#.stretch(0,1800)
while True:
    new_depth = cam.getDepth()#.stretch(0,1800)
    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.morphOpen()
    motion_img_open.show()
    depth = new_depth
Exemplo n.º 10
0
from SimpleCV import Kinect
import time

# Initialize the Kinect
kin = Kinect()

# Get the image and depth information
dep = kin.getDepth()
img = kin.getImage()

# Turn into a pure black and white image for segmentation
fore = dep.binarize(190).invert()
fore_only = img - fore

fore_only.show()

# Keep the image open for 10 seconds
time.sleep(10)