Exemplo n.º 1
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()
Exemplo n.º 2
0
def main():
    picture = 'shot.png'
    at = get_access_token()
    cam = Camera()
    display = Display((800, 600))
    while display.isNotDone():
        img = cam.getImage()
        img.save(picture)
        img.save(display)
        content = FaceRecognization(at, picture)
        print(content)
        print(content['height'])
Exemplo n.º 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()
Exemplo n.º 4
0
def main():
    while (IfWIFI()):
        print("No WIFI")
    picture = 'shot.jpg'
    at = get_access_token()
    cam = Camera()
    display = Display((800, 600))
    a = 1
    b = 0
    while display.isNotDone():
        count = ser.inWaiting()
        if count != 0:
            recv = ser.read(count)
            print(type(recv))
            if recv[0] == '*' and recv[-1] == '#':
                print("detected")
                img = cam.getImage()
                img.save(picture)
                img.save(display)
                name = MarketRecognization(at, picture)
                print(name)
                if name == "Bread":
                    b = 1
                if name == "Cookies":
                    b = 2
                if name == "HotStrips":
                    b = 3
                if name == "Sepals":
                    b = 4
                if name == "EggRolls":
                    b = 5
                if name == "Beans":
                    b = 6
                ser.write("*,%s,%s,#" % (a, b))
        ser.flushInput()
        time.sleep(0.1)
Exemplo n.º 5
0
'''

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.drawRectangle(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.drawText("reading barcode... wait", 10, 10)
        img.save(display)
        barcode = img.findBarcode()
        if barcode:  # if we have a barcode
            data = str(barcode.data)
            print data
Exemplo n.º 6
0
import time, webbrowser
from operator import add
from SimpleCV import Color, ColorCurve, Camera, Image, pg, np, cv
from SimpleCV.Display import Display

cam = Camera(0)
time.sleep(.1) # uhg
display = Display((800,600))
counter = 0
# load the cascades
face_cascade = cv.Load("./../Features/HaarCascades/face.xml")
nose_cascade = cv.Load("./../Features/HaarCascades/nose.xml")
stache = Image("./stache.png") # load the stache
mask = stache.createAlphaMask() # load the stache mask
count = 0
while( display.isNotDone() ):
    #count = count + 1
    img = cam.getImage()
    img = img.scale(.5) #use a smaller image
    faces = img.findHaarFeatures(face_cascade) #find faces
    if( faces is not None ): # if we have a face
        faces = faces.sortArea() #get the biggest one
        face = faces[-1]
        myFace = face.crop() # get the face image
        noses = myFace.findHaarFeatures(nose_cascade) #find the nose
        if( noses is not None ):# if we have a nose
            noses = noses.sortArea()
            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.width()/2)
Exemplo n.º 7
0
from SimpleCV import Color, Image, np, Camera
from SimpleCV.Display import Display
cam = Camera(0)
display = Display((640, 480))  # create our display

quality = 400.00
minDist = 0.35
minMatch = 0.2
template_img = None
mode = "untrained"
startX = None
startY = None
endY = None
endX = None

while (display.isNotDone()):
    img = cam.getImage().resize(640, 480)

    #Display this if a template has not been trained yet
    if mode == "untrained":
        if startX == None or startY == None:
            img.dl().text("Click the upper left corner to train", (10, 10))
            if display.mouseLeft:
                startX = display.mouseRawX
                startY = display.mouseRawY
                time.sleep(0.2)
        elif endX == None or endY == None:
            img.dl().text("now click the lower right corner to train",
                          (10, 10))
            if display.mouseLeft:
                endX = display.mouseX
Exemplo n.º 8
0
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.drawRectangle(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.drawText("reading barcode... wait",10,10)
        img.save(display)
        barcode = img.findBarcode()
        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.drawText("Click to scan.",10,10,color=Color.RED)
Exemplo n.º 9
0
from mouse_api import *
m = Mouse()
nf = 2
h = 0
fl=[]
reset = 0

while h<nf:
	h = h + 1
	snap = cam.getImage()                
	d = Display(snap.size())
	snap.save(d)
	col = Color.RED
	start_time = time.time()
	i=0
	while d.isNotDone():
	    elapsed_time = time.time() - start_time
	    if d.mouseLeft:
	        txt = "coord: (" + str(d.mouseX) + "," + str(d.mouseY) + ")"
	        snap.dl().text(txt, (10,snap.height / 2), color=col)
	        txt = "color: " + str(snap.getPixel(d.mouseX,d.mouseY))
	        snap.dl().text(txt, (10,(snap.height / 2) + 10), color=col)
	        print "coord: (" + str(d.mouseX) + "," + str(d.mouseY) + "), color: " + str(snap.getPixel(d.mouseX,d.mouseY))
	        if i==1:    
	            x2=d.mouseX
	            y2=d.mouseY
	            time.sleep(1)      
	    if d.mouseLeft:
	        if i==0:
	            x1=d.mouseX
	            y1=d.mouseY
Exemplo n.º 10
0
from mouse_api import *
m = Mouse()
nf = 2
h = 0
fl = []
reset = 0

while h < nf:
    h = h + 1
    snap = cam.getImage()
    d = Display(snap.size())
    snap.save(d)
    col = Color.RED
    start_time = time.time()
    i = 0
    while d.isNotDone():
        elapsed_time = time.time() - start_time
        if d.mouseLeft:
            txt = "coord: (" + str(d.mouseX) + "," + str(d.mouseY) + ")"
            snap.dl().text(txt, (10, snap.height / 2), color=col)
            txt = "color: " + str(snap.getPixel(d.mouseX, d.mouseY))
            snap.dl().text(txt, (10, (snap.height / 2) + 10), color=col)
            print "coord: (" + str(d.mouseX) + "," + str(
                d.mouseY) + "), color: " + str(
                    snap.getPixel(d.mouseX, d.mouseY))
            if i == 1:
                x2 = d.mouseX
                y2 = d.mouseY
                time.sleep(1)
        if d.mouseLeft:
            if i == 0: