Exception of imports
This commit is contained in:
		
							parent
							
								
									a82b98154f
								
							
						
					
					
						commit
						e17b2bf461
					
				
							
								
								
									
										35
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								main.py
									
									
									
									
									
								
							@ -1,21 +1,20 @@
 | 
			
		||||
 | 
			
		||||
from time import sleep
 | 
			
		||||
from PIL import Image
 | 
			
		||||
import os
 | 
			
		||||
import serial
 | 
			
		||||
import sys
 | 
			
		||||
import os
 | 
			
		||||
import json
 | 
			
		||||
import datetime
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    import numpy as np
 | 
			
		||||
    from picamera import PiCamera
 | 
			
		||||
    from picamera.array import PiRGBArray
 | 
			
		||||
    import cv2
 | 
			
		||||
    
 | 
			
		||||
	import numpy as np
 | 
			
		||||
	from picamera import PiCamera
 | 
			
		||||
	from picamera.array import PiRGBArray
 | 
			
		||||
	import serial
 | 
			
		||||
	import cv2
 | 
			
		||||
 | 
			
		||||
except Exception as ex:
 | 
			
		||||
    print('[ Error ] some depandincies are missing\n'+ str(ex.args))
 | 
			
		||||
    sys.exit()
 | 
			
		||||
	print('[ Error ] some depandincies are missing\n'+ str(ex.args))
 | 
			
		||||
	sys.exit()
 | 
			
		||||
 | 
			
		||||
def init():
 | 
			
		||||
	go = True
 | 
			
		||||
@ -36,17 +35,17 @@ def init():
 | 
			
		||||
	except:
 | 
			
		||||
		print('[ Error ] Can not load cascade File')
 | 
			
		||||
		go = False
 | 
			
		||||
	try: 
 | 
			
		||||
	try:
 | 
			
		||||
		os.mkdir('unknown')
 | 
			
		||||
	except OSError as ex:
 | 
			
		||||
		print('Found (unknown) folder')
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
	if (go):
 | 
			
		||||
		print('Starting Photo loop..')
 | 
			
		||||
		print('Known people are '+str(loadNames()))
 | 
			
		||||
		start(camera, face_cascade)
 | 
			
		||||
		
 | 
			
		||||
	else: 
 | 
			
		||||
 | 
			
		||||
	else:
 | 
			
		||||
		print('closing')
 | 
			
		||||
 | 
			
		||||
def start( camera, face_cascade):
 | 
			
		||||
@ -88,16 +87,16 @@ def start( camera, face_cascade):
 | 
			
		||||
			else:
 | 
			
		||||
				print('Found '+person)
 | 
			
		||||
				OpenShifter()
 | 
			
		||||
		cv2.imshow('image',img) 
 | 
			
		||||
		cv2.imshow('image',img)
 | 
			
		||||
		cv2.waitKey(1)
 | 
			
		||||
		rawCapture.truncate(0)
 | 
			
		||||
		if cv2.waitKey(1) & 0xFF == ord('q'):
 | 
			
		||||
			cv2.destroyAllWindows()
 | 
			
		||||
			break
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def recognize(image,face_recognizer, names):
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	try:
 | 
			
		||||
		img = image.copy()
 | 
			
		||||
		label= face_recognizer.predict(img)
 | 
			
		||||
@ -127,7 +126,7 @@ def OpenShifter():
 | 
			
		||||
			ser.close()
 | 
			
		||||
		except:
 | 
			
		||||
			print('[ Error ] Can not connect to Arduino at /dev/ttyUSB1 ..')
 | 
			
		||||
			
 | 
			
		||||
 | 
			
		||||
def loadNames():
 | 
			
		||||
	try:
 | 
			
		||||
		with open("faces/names.json", "r") as read_file:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user