Beispiel #1
0
def main():
    """Finds and interprets feature points"""

    # Initialize Camera
    print "Starting Webcam..."
    try:
        cam = Camera()
    except:
	print "Unable to initialize camera"
	sys.exit(1)

    display = Display(resolution = (RES_WIDTH, RES_HEIGHT))
    while not display.isDone():
        # capture the current frame
        try: 
	    capture = cam.getImage()
	    img = capture.smooth()
	except cv.error:
	    print "Camera unsupported by OpenCV"
	    sys.exit(1)

        # Build face and interpret expression
	face_image = FaceImage(img)
	if face_image.face:
	  #s  face_image.interpret()
	    pass

	capture.save(display)
	time.sleep(0.01)
	if display.mouseLeft:
	    display.done = True
Beispiel #2
0
    def live(self):
        """
        **SUMMARY**

        This shows a live view of the camera.

        **EXAMPLE**

        To use it's as simple as:

        >>> cam = Camera()
        >>> cam.live()

        Left click will show mouse coordinates and color
        Right click will kill the live image
        """

        start_time = time.time()

        from SimpleCV.Display import Display
        i = self.getImage()
        d = Display(i.size())
        i.save(d)
        col = Color.RED

        while d.isNotDone():
            i = self.getImage()
            elapsed_time = time.time() - start_time

            if d.mouseLeft:
                txt = "coord: (" + str(d.mouseX) + "," + str(d.mouseY) + ")"
                i.dl().text(txt, (10, i.height / 2), color=col)
                txt = "color: " + str(i.getPixel(d.mouseX, d.mouseY))
                i.dl().text(txt, (10, (i.height / 2) + 10), color=col)
                print "coord: (" + str(d.mouseX) + "," + str(
                    d.mouseY) + "), color: " + str(
                        i.getPixel(d.mouseX, d.mouseY))

            if elapsed_time > 0 and elapsed_time < 5:

                i.dl().text("In live mode", (10, 10), color=col)
                i.dl().text("Left click will show mouse coordinates and color",
                            (10, 20),
                            color=col)
                i.dl().text("Right click will kill the live image", (10, 30),
                            color=col)

            i.save(d)
            if d.mouseRight:
                print "Closing Window"
                d.done = True

        pg.quit()
Beispiel #3
0
    def live(self):
        """
        **SUMMARY**

        This shows a live view of the camera.

        **EXAMPLE**

        To use it's as simple as:

        >>> cam = Camera()
        >>> cam.live()

        Left click will show mouse coordinates and color
        Right click will kill the live image
        """

        start_time = time.time()
        
        from SimpleCV.Display import Display
        i = self.getImage()
        d = Display(i.size())
        i.save(d)
        col = Color.RED

        while d.isNotDone():
          i = self.getImage()
          elapsed_time = time.time() - start_time
          

          if d.mouseLeft:
            txt = "coord: (" + str(d.mouseX) + "," + str(d.mouseY) + ")"
            i.dl().text(txt, (10,i.height / 2), color=col)
            txt = "color: " + str(i.getPixel(d.mouseX,d.mouseY))
            i.dl().text(txt, (10,(i.height / 2) + 10), color=col)
            print "coord: (" + str(d.mouseX) + "," + str(d.mouseY) + "), color: " + str(i.getPixel(d.mouseX,d.mouseY))


          if elapsed_time > 0 and elapsed_time < 5:
            
            i.dl().text("In live mode", (10,10), color=col)
            i.dl().text("Left click will show mouse coordinates and color", (10,20), color=col)
            i.dl().text("Right click will kill the live image", (10,30), color=col)

          
          i.save(d)
          if d.mouseRight:
            print "Closing Window"
            d.done = True

        
        pg.quit()
Beispiel #4
0
        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())

    imgscene = imgscene.crop(0,25, 605, 455).scale(640,480)

    frame = ((imgscene - compositeframe.binarize(10).invert()) + compositeframe) + imgscene.edges()#.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
    num = frame.getNumpy()
    Image(num).save(d)
    #frame.save(d) #show in browser
    if d.mouseLeft:
        d.done = True
        pg.quit()

    time.sleep(0.01) #yield to the webserver
Beispiel #5
0
#!/usr/bin/python 

import time
from SimpleCV import *
from SimpleCV.Display import Display, pg

display = Display(resolution = (800, 600)) #create a new display to draw images on
cam = Camera() #initialize the camera
done = False # setup boolean to stop the program

# Loop until not needed
while not display.isDone():
    cam.getImage().flipHorizontal().save(display) # get image, flip it so it looks mirrored, save to display
    time.sleep(0.01) # Let the program sleep for 1 millisecond so the computer can do other things
    if display.mouseLeft:
        display.done = True #if the left arrow is pressed, close the program
from SimpleCV import *
from SimpleCV.Display import Display 
import xaut
mouse = xaut.mouse()
delay = mouse.move_delay(0)
custom_red = (121.0, 41.0, 37.0)
disp = Display(resolution=(640,480))
white_img = Image((640,480)).invert()
YELLOW=(179.0, 195.0, 112.0)
cam = Camera()

while not disp.isDone():
	original_img = cam.getImage().flipHorizontal()
	red_distance_img = original_img.colorDistance(color=Color.RED)
	red_bin = red_distance_img.threshold(100).invert()
	blobs = red_bin.findBlobs(minsize=50,maxsize=10720)
	if(blobs is not None):
		blob = max(blobs)
		mouse.move(15*(blob.x-256),12.5*(blob.y-192))
	red_bin.save(disp)
	if disp.mouseLeft:
		disp.done = True
		xaut.cleanup()
Beispiel #7
0
#!/usr/bin/python

import time
from SimpleCV import *
from SimpleCV.Display import Display, pg

display = Display(resolution=(800,
                              600))  #create a new display to draw images on
cam = Camera()  #initialize the camera
done = False  # setup boolean to stop the program

# Loop until not needed
while not display.isDone():
    cam.getImage().flipHorizontal().save(
        display)  # get image, flip it so it looks mirrored, save to display
    time.sleep(
        0.01
    )  # Let the program sleep for 1 millisecond so the computer can do other things
    if display.mouseLeft:
        display.done = True  #if the left arrow is pressed, close the program