From e17b2bf4615a52f90b4f263a154bd91435e5f7a2 Mon Sep 17 00:00:00 2001 From: hesham Date: Sat, 19 Jan 2019 20:11:37 +0300 Subject: [PATCH] Exception of imports --- main.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/main.py b/main.py index 45bea94..432390a 100644 --- a/main.py +++ b/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: -- 2.39.5