old_contents: #!/usr/bin/python 
  
  import time, webbrowser
  from operator import add
  from SimpleCV import VideoStream, JpegStreamer, Kinect, Image
  import numpy as np
  
  vs = VideoStream("foo.avi")
  js = JpegStreamer()
  #create video streams
  
  cam = Kinect()
  #initialize the camera
  
  cam.getDepth().save(js)
  webbrowser.open(js.url())
  #launch the webbrowser
  
  compositeframe = Image(cam.getImage().getEmpty())
  #populate the compositeframe
  
  offtime = 3.0
  paintstate = False
  laststroke = time.time()
  
  while (1):
    depth = cam.getDepth().invert().binarize(100)
    #perform a binary threshold of the inverted depth map
    
    if np.average(depth.getMatrix()) > 1:  #if there is action
      paintstate = True
      laststroke = time.time()
      compositeframe = compositeframe + depth
      #we're painting -- keep adding to the composite frame
    else:
      paintstate = False
      #not painting
      if (time.time() - laststroke > offtime):
        #if we're not painting for a certain amount of time, reset
        compositeframe = Image(cam.getImage().getEmpty())
  
    frame = ((cam.getImage() - compositeframe) + compositeframe.splitChannels(False)[0]).flipHorizontal()
    #subtract our composite frame from our camera image, then add it back in in red. False = Show red channel as red, [0] = first (red) channel
    frame.save(js) #show in browser
    frame.save(vs) #save in file
    time.sleep(0.01) #yield to the webserver
  
new_contents: #!/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(flags = pg.FULLSCREEN)
  #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.dl().blit(img.crop(100, 0, 515, 480), (125,0))
        #this is a bit of a hack to compensate for the offset between cam and depth sensor
        img = img.applyLayers()
        img = img - depthbin.invert()
    
        meanred, meangrn, meanblue = img.meanColor()
    
        if meanred > meanblue and meanred > meangrn:
            depthbin, junk, junk = depthbin.splitChannels(grayscale = False)
        if meanblue > meanred and meanblue > meangrn:
            junk, junk, depthbin = depthbin.splitChannels(grayscale = False)
        if meangrn > meanred and meangrn > meanblue:
            junk, depthbin, junk = depthbin.splitChannels(grayscale = False)
    
        laststroke = time.time()
        compositeframe = compositeframe + depthbin
        #we're painting -- keep adding to the composite frame
    
    else:
        if (time.time() - laststroke > offtime):
        #if we're not painting for a certain amount of time, reset
            compositeframe = Image(cam.getImage().getEmpty())
  
    frame = ((imgscene - compositeframe.binarize(10).invert()) + compositeframe).flipHorizontal()
    #subtract our composite frame from our camera image, then add it back in in red. False = Show red channel as red, [0] = first (red) channel
    frame.save(d) #show in browser
    if d.mouseLeft:
        d.done = True
        pg.quit()
        
    time.sleep(0.01) #yield to the webserver
  
subject: add coloring