def servoturn():
	servo = Servo("s1")
	servo.attach(3)
	time.sleep(0.05)
		
        # From 0 to 180 degrees
	for angle in range(0,180):
		servo.write(angle)
		time.sleep(0.05)
def facial_rec():
	out_dir = None
	servo = Servo("s1")
	servo.attach(3) #attaches to pin 3 in pwm
	print("New picture has been found in library")
	# if len(sys.argv) < 2:
		# print "USAGE: facerec_demo.py </path/to/images> [</path/to/store/images/at>]"
		# sys.exit()
		# Now read in the image data. This must be a valid path!
	[X,y] = read_images(sys.argv[1], (200, 100))

	face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")

	img = cv2.imread(os.path.join(sys.argv[1], 'face.png'))
	gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
	faces = face_cascade.detectMultiScale(gray, 1.3, 5)
	for (p,q,r,s) in faces:
		cv2.rectangle(gray,(p,q),(p+r,q+s),(150,125,0),2)#drawing a rectangle indicating face
		sample = gray[q:q+s, p:p+r]
	# resize to given size (if given)
	sample = cv2.resize(gray, (200,100))

	sIm = np.frombuffer(sample, dtype=np.uint8)
	y = np.asarray(y, dtype=np.int32)
	if len(sys.argv) == 3:
		out_dir = sys.argv[2]
	model = cv2.createFisherFaceRecognizer()
	model.train(np.asarray(X), np.asarray(y))

	[p_label, p_confidence] = model.predict(np.asarray(sIm)) #replace sIm with another 
	print "Predicted label = %d (confidence=%.2f)" % (p_label, p_confidence)

	if(p_confidence > 0):
		print "Face does not match"
		blinkLed = mraa.Gpio(LED_GPIO3) # Get the LED pin object
		blink(blinkLed)
	else: 
		print "Face Matches!!!!!"
		
		servoturn()
		
	if out_dir is None:
		cv2.waitKey(0)
示例#3
0
def main():
    servo1 = Servo("First Servo")
    servo1.attach(5)
    servo2 = Servo("Second Servo")
    servo2.attach(3)
    servo1.write(86)
    servo2.write(85)
    servo3 = Servo("Third Servo")
    servo3.attach(6)
    servo3.write(87)
    oldDoor = "False"
    while 1:
        # print "shoot"
        # shoot(servo1,servo2)
        # time.sleep(2)

        print "start"
        try:
            match, ready, confidence, door = callApi()
            print "good"
            print "door", door
            if door != oldDoor:
                print door,
                print oldDoor
                oldDoor = door
                moveDoor(door, servo3)
            if ready == "True":
                if match == "False" or confidence < 0.58:
                    shoot(servo1, servo2)
                    print "shoot"
        except:
            print "bad"
示例#4
0
----------------------------------------------------------
    Author		   Date		  Description
----------------------------------------------------------
Diego Villalobos	02-12-2015	Example created

"""

# Libraries required
from Servo import *
import time

# Create a new servo object with a reference name
myServo = Servo("First Servo")

# Attaches the servo to pin 3 in Arduino Expansion board
myServo.attach(3)

# Print servo settings
print ""
print "*** Servo Initial Settings ***"
print myServo
print ""

try:
    # Sweeps the servo motor forever
    while True:
        # From 0 to 180 degrees
        for angle in range(0,180):
            myServo.write(angle)
            time.sleep(0.005)
示例#5
0
import cv2
import urllib
import time
import numpy as np
import mraa
from Servo import *
myServo = Servo("Servo")
myServo.attach(9)

def getFrame(Camera_IP):

        imageFile = urllib.URLopener()
        imageFile.retrieve("http://"+ Camera_IP + ":8080/shot.jpg", 'shot.jpg')

def main():
        
        face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
        camIP = raw_input("Insert your android camera's IP: ")

        while(1):
                getFrame(camIP)
                img = cv2.imread('shot.jpg',0)
                faces = face_cascade.detectMultiScale(img, 1.3, 5)
                if len (faces) > 0:
                        print ("Rostro Detectado!")
                        for angle in range(0,180):
                                myServo.write(angle)
                                time.sleep(0.005)
                        # From 180 to 0 degrees
                        for angle in range(180,-1,-1):
                                myServo.write(angle)
示例#6
0
文件: Sweep.py 项目: sorphin/Edison
----------------------------------------------------------
    Author		   Date		  Description
----------------------------------------------------------
Diego Villalobos	02-12-2015	Example created

"""

# Libraries required
from Servo import *
import time

# Create a new servo object with a reference name
myServo = Servo("First Servo")

# Attaches the servo to pin 3 in Arduino Expansion board
myServo.attach(3)

# Print servo settings
print ""
print "*** Servo Initial Settings ***"
print myServo
print ""

try:
    # Sweeps the servo motor forever
    while True:
        # From 0 to 180 degrees
        for angle in range(0, 180):
            myServo.write(angle)
            time.sleep(0.005)
示例#7
0
    myLCD.write("FaceLock")
    myLCD.setCursor(1, 0)
    myLCD.write("Press button")

    servo.write(0)


BUTTON_PIN = 2
button = mraa.Gpio(BUTTON_PIN)
button.dir(mraa.DIR_IN)

## The LCD can only display 16 characters per line
myLCD = lcd.Jhd1313m1(0, 0x3E, 0x62)

servo = Servo("Lock")
servo.attach(3)

greeting()

while True:

    if button.read():

        permissionGranted = authenticate()

        if permissionGranted:
            granted()
        else:
            denied()

        greeting()
示例#8
0
from Servo import *
import time, sys
leftRight = Servo("First Servo")
upDown = Servo("Second Servo")
# Attaches the servo to pin 3 in Arduino Expansion board
leftRight.attach(3)
upDown.attach(5)

for angle in range(90, 110):
    leftRight.write(angle)
    time.sleep(0.005)
for angle in range(70, 120):
    upDown.write(angle)
    time.sleep(0.005)

for angle in range(120, 70, -1):
    upDown.write(angle)
    time.sleep(0.005)
for angle in range(110, 90, -1):
    leftRight.write(angle)
    time.sleep(0.005)
示例#9
0
	myLCD.setCursor(0, 0)
	myLCD.write("FaceLock")
	myLCD.setCursor(1, 0)
	myLCD.write("Press button")

	servo.write(0)

BUTTON_PIN = 2
TRAINING_BUTTON_PIN = 8
button = mraa.Gpio(BUTTON_PIN)
training_button = mraa.Gpio(TRAINING_BUTTON_PIN)
button.dir(mraa.DIR_IN)
training_button.dir(mraa.DIR_IN)

## The LCD can only display 16 characters per line
myLCD = lcd.Jhd1313m1(0, 0x3E, 0x62)

servo = Servo("Lock")
servo.attach(3)

greeting()

while True:

	if button.read():
		authenticate() 
	if training_button.read():
		training_interface.begin_training()
        greeting()
	time.sleep(0.1)