Graduate

Update app.py

...@@ -44,6 +44,9 @@ def get_distance(arr1, arr2): ...@@ -44,6 +44,9 @@ def get_distance(arr1, arr2):
44 distance = np.linalg.norm(arr1 - arr2) 44 distance = np.linalg.norm(arr1 - arr2)
45 return distance 45 return distance
46 46
47 +def get_brightness(arr):
48 + return np.average(np.linalg.norm(arr, axis=2)) / np.sqrt(3)
49 +
47 @app.route('/') 50 @app.route('/')
48 def index(): 51 def index():
49 """Video streaming page""" 52 """Video streaming page"""
...@@ -74,6 +77,8 @@ def register(): ...@@ -74,6 +77,8 @@ def register():
74 image = base64.b64decode(request.form['image']) 77 image = base64.b64decode(request.form['image'])
75 image_np = np.frombuffer(image, dtype=np.uint8) 78 image_np = np.frombuffer(image, dtype=np.uint8)
76 image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED) 79 image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED)
80 + # change brightness
81 + # cv2.add(image_np, np.array([x]))
77 image_np = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB) 82 image_np = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB)
78 image_np = prewhiten(image_np) 83 image_np = prewhiten(image_np)
79 image_np = resize(image_np) 84 image_np = resize(image_np)
...@@ -101,6 +106,7 @@ def verify(): ...@@ -101,6 +106,7 @@ def verify():
101 image = base64.b64decode(request.form['image']) 106 image = base64.b64decode(request.form['image'])
102 image_np = np.frombuffer(image, dtype=np.uint8) 107 image_np = np.frombuffer(image, dtype=np.uint8)
103 image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED) 108 image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED)
109 + print(get_brightness(image_np))
104 image_np = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB) 110 image_np = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB)
105 image_np = prewhiten(image_np) 111 image_np = prewhiten(image_np)
106 image_np = resize(image_np) 112 image_np = resize(image_np)
......