def post(self): args = parse_args() if args['type'] == 'face': m = FaceDetect.Face() elif args['type'] in [None, 'object']: m = ObjectDetect.Object() else: abort(400, msg='Invalid Model:{}'.format(args['type'])) fip, ext = get_file(args) detections = m.detect(fip, ext, args) return detections
if not db.check_credentials(username, password): abort(401, message='incorrect credentials') # Identity can be any data that is json serializable access_token = create_access_token(identity=username) response = jsonify(access_token=access_token, expires=g.ACCESS_TOKEN_EXPIRES) response.status_code = 200 return response # main init #inizializzi i modelli per risparmiare tempo poi! coral_m = ObjectDetectCoral.ObjectCoral() object_m = ObjectDetect.Object() app = Flask(__name__) def get_http_exception_handler(app): """Overrides the default http exception handler to return JSON.""" handle_http_exception = app.handle_http_exception @wraps(handle_http_exception) def ret_val(exception): exc = handle_http_exception(exception) return jsonify({'code': exc.code, 'msg': exc.description}), exc.code return ret_val
def function_to_run_only_once(): face_obj = FaceRecog.Face() od_obj = ObjectDetect.Object()
# If you want to use ZM # note your URL may need /cgi-bin/zm/nph-zms - make sure you specify it correctly # CAPTURE_SRC='https://demo.zoneminder.com/cgi-bin-zm/nph-zms?mode=jpeg&maxfps=5&buffer=1000&monitor=18&user=zmuser&pass=zmpass' #--------- end ---------------------------- ap = argparse.ArgumentParser() ap.add_argument('-c', '--config', required=True, help='config file with path') ap.add_argument('-s', '--source', required=True, help='source file') args, u = ap.parse_known_args() args = vars(args) utils.process_config(args) import modules.object as ObjectDetect od_obj = ObjectDetect.Object() #pb_dir = '/home/iconnor/Downloads/ssd_mobilenet_v2_coco_2018_03_29' pb_dir = '/home/iconnor/ssdlite_mobilenet_v2_coco_2018_05_09' pb = pb_dir + '/frozen_inference_graph.pb' pbtxt = pb_dir + '/frozen_inference_graph.pbtxt' tfNet = cv2.dnn.readNetFromTensorflow(pb, pbtxt) login_url = BASE_API_URL + '/login' object_url = BASE_API_URL + '/detect/object' access_token = None auth_header = None # Draws bounding box around detections def draw_boxes(frame, data):