Esempio n. 1
0
def find_face():
	print("TODO: Entering authenticate() stub")

   	myLCD.clear()
	myLCD.setColor(255, 255, 0)
	myLCD.setCursor(0, 0)
	myLCD.write("Taking picture...")

	time.sleep(2)
	img = recognizer.take_picture()
	myLCD.clear()
	myLCD.setCursor(0,0)
	myLCD.write("Searching for")
	myLCD.setCursor(1,0)
	myLCD.write("faces...")
	images = recognizer.check_for_face(img)
	
	numfaces = len(images)
	print numfaces
	if numfaces == 0:
		myLCD.clear()
		myLCD.setColor(255, 0, 0)
		myLCD.setCursor(0,0)
		myLCD.write("Face not detected")
		time.sleep(2)
		return None
	else:
		return images	
def take_pictures():
	num_pics = 1
	while(num_pics < (MAX_PICTURES + 1)):
		myLCD.clear()
		myLCD.setColor(255, 255, 0)
		myLCD.setCursor(0, 0)
		myLCD.clear()
                myLCD.write("1...")
                time.sleep(1)
                myLCD.write("2...")
                time.sleep(1)
		myLCD.write("3...")
		time.sleep(1)
		myLCD.clear()
		myLCD.write("Taking picture")
		myLCD.setCursor(1, 0)
		myLCD.write("number %d" %num_pics)
		time.sleep(1)
		img = recognizer.take_picture()
		myLCD.clear()
		myLCD.setColor(255, 255, 0)
		myLCD.setCursor(0, 0)
		myLCD.write("Processing...")
		time.sleep(.5)
		gc_img = recognizer.check_for_face(img)
		if len(gc_img) == 1:
			pic_name = "subject"+str(subject_number)+"."+"picture"+str(num_pics)+".png"
			recognizer.save_picture('temp_pics_for_training',pic_name, gc_img[0])
			num_pics = num_pics + 1
			myLCD.clear()
			myLCD.setColor(0, 255, 0)
			myLCD.write("Success!")
			time.sleep(1)
		elif len(gc_img) > 1:
			myLCD.clear()
			myLCD.setColor(255, 0, 0)
                        myLCD.write("Faces > 1.")
                        myLCD.setCursor(1,0)
                        myLCD.write("... try again.")
			time.sleep(1) 
		else:
			myLCD.clear()
			myLCD.setColor(255, 0, 0)
			myLCD.write("No face found.")
			myLCD.setCursor(1,0)
			myLCD.write("... try again.")
			time.sleep(1)