Showing
3 changed files
with
5 additions
and
4 deletions
... | @@ -11,6 +11,7 @@ import tensorflow as tf | ... | @@ -11,6 +11,7 @@ import tensorflow as tf |
11 | import base64 | 11 | import base64 |
12 | import pymysql | 12 | import pymysql |
13 | import configparser | 13 | import configparser |
14 | +import uuid | ||
14 | from PIL import Image | 15 | from PIL import Image |
15 | 16 | ||
16 | config = configparser.ConfigParser() | 17 | config = configparser.ConfigParser() |
... | @@ -74,8 +75,8 @@ def register(): | ... | @@ -74,8 +75,8 @@ def register(): |
74 | image = base64.b64decode(request.form['image']) | 75 | image = base64.b64decode(request.form['image']) |
75 | image_np = np.frombuffer(image, dtype=np.uint8) | 76 | image_np = np.frombuffer(image, dtype=np.uint8) |
76 | image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED) | 77 | image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED) |
77 | - image_np = resize(image_np) | ||
78 | image_np = prewhiten(image_np) | 78 | image_np = prewhiten(image_np) |
79 | + image_np = resize(image_np) | ||
79 | image_np = image_np.reshape(-1, image_size, image_size, 3) | 80 | image_np = image_np.reshape(-1, image_size, image_size, 3) |
80 | # get embedding | 81 | # get embedding |
81 | feed_dict = {input_placeholder:image_np, phase_train_placeholder:False } | 82 | feed_dict = {input_placeholder:image_np, phase_train_placeholder:False } |
... | @@ -100,8 +101,8 @@ def verify(): | ... | @@ -100,8 +101,8 @@ def verify(): |
100 | image = base64.b64decode(request.form['image']) | 101 | image = base64.b64decode(request.form['image']) |
101 | image_np = np.frombuffer(image, dtype=np.uint8) | 102 | image_np = np.frombuffer(image, dtype=np.uint8) |
102 | image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED) | 103 | image_np = cv2.imdecode(image_np, cv2.IMREAD_UNCHANGED) |
103 | - image_np = resize(image_np) | ||
104 | image_np = prewhiten(image_np) | 104 | image_np = prewhiten(image_np) |
105 | + image_np = resize(image_np) | ||
105 | image_np = image_np.reshape(-1, image_size, image_size, 3) | 106 | image_np = image_np.reshape(-1, image_size, image_size, 3) |
106 | # get embedding | 107 | # get embedding |
107 | feed_dict = {input_placeholder:image_np, phase_train_placeholder:False } | 108 | feed_dict = {input_placeholder:image_np, phase_train_placeholder:False } | ... | ... |
... | @@ -127,7 +127,7 @@ function processVideo() { | ... | @@ -127,7 +127,7 @@ function processVideo() { |
127 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); | 127 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); |
128 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255], 8); | 128 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255], 8); |
129 | let cropped = new cv.Mat(); | 129 | let cropped = new cv.Mat(); |
130 | - let rect = new cv.Rect(Math.max(face.x-face.width/4, 0), Math.max(face.y-face.height/2, 0), Math.min(face.width+face.width/2, src.cols), Math.min(face.height*2, src.rows)); | 130 | + let rect = new cv.Rect(Math.max(face.x-22, 0), Math.max(face.y-44, 0), Math.min(face.width+44, src.cols), Math.min(face.height+66, src.rows)); |
131 | cropped = src.roi(rect); | 131 | cropped = src.roi(rect); |
132 | let tempCanvas = document.createElement("canvas"); | 132 | let tempCanvas = document.createElement("canvas"); |
133 | cv.imshow(tempCanvas,cropped); | 133 | cv.imshow(tempCanvas,cropped); | ... | ... |
... | @@ -61,7 +61,7 @@ function detect_face() | ... | @@ -61,7 +61,7 @@ function detect_face() |
61 | let point1 = new cv.Point(face.x, face.y); | 61 | let point1 = new cv.Point(face.x, face.y); |
62 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); | 62 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); |
63 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255], 8); | 63 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255], 8); |
64 | - let rect = new cv.Rect(Math.max(face.x-face.width/4, 0), Math.max(face.y-face.height/2, 0), Math.min(face.width+face.width/2, src.cols), Math.min(face.height*2, src.rows)); | 64 | + let rect = new cv.Rect(Math.max(face.x-22, 0), Math.max(face.y-44, 0), Math.min(face.width+44, src.cols), Math.min(face.height+66, src.rows)); |
65 | let cropped = src.roi(rect); | 65 | let cropped = src.roi(rect); |
66 | cv.imshow(tempCanvas,cropped); | 66 | cv.imshow(tempCanvas,cropped); |
67 | } | 67 | } | ... | ... |
-
Please register or login to post a comment