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