You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. from modules import utils
  2. from flask import Flask, request, Response
  3. from flask_restful import Resource, Api
  4. from PIL import Image
  5. import base64
  6. import json
  7. import sys
  8. import os
  9. import io
  10. if sys.platform == "win32":
  11. import tensorflow as tf
  12. import numpy as np
  13. import pickle
  14. sys.path.insert(0, r'C:\Users\Tednokent01\Downloads\MyCity\traffic_analyzer')
  15. from utils import label_map_util
  16. from utils import visualization_utils as vis_util
  17. app = Flask(__name__)
  18. api = Api(app)
  19. db_path = os.path.join(app.root_path, 'databases', 'crashes.json')
  20. with open(db_path, 'r') as f:
  21. crashes = json.load(f)
  22. users_path = os.path.join(app.root_path, 'databases', 'users.json')
  23. with open(users_path, 'r') as f:
  24. users = json.load(f)
  25. if sys.platform == "win32":
  26. PATH_TO_LABELS = '../../traffic_analyzer/object_detection/data/kitti_label_map.pbtxt'
  27. PATH_TO_CKPT = 'modules/faster_rcnn_resnet101_kitti_2018_01_28/frozen_inference_graph.pb'
  28. category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)
  29. def process_img(img):
  30. pass
  31. class Crash(Resource):
  32. def post(self):
  33. message = request.form['message']
  34. base64_img = request.form['img']
  35. id = request.form['id']
  36. process_img(Image.open(io.BytesIO(base64.b64decode(base64_img))))
  37. return id