Showing
4 changed files
with
25 additions
and
19 deletions
1 | -from flask import Flask, render_template, Response, request | 1 | +from flask import Flask, render_template, Response, request, jsonify |
2 | +import json | ||
2 | import cv2 | 3 | import cv2 |
3 | import numpy as np | 4 | import numpy as np |
4 | import time | 5 | import time |
... | @@ -6,7 +7,6 @@ import datetime | ... | @@ -6,7 +7,6 @@ import datetime |
6 | import sys | 7 | import sys |
7 | 8 | ||
8 | faceCascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml") | 9 | faceCascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml") |
9 | -num = 3 | ||
10 | app = Flask(__name__) | 10 | app = Flask(__name__) |
11 | 11 | ||
12 | @app.route('/') | 12 | @app.route('/') |
... | @@ -15,7 +15,11 @@ def index(): | ... | @@ -15,7 +15,11 @@ def index(): |
15 | return render_template('index.html') | 15 | return render_template('index.html') |
16 | 16 | ||
17 | 17 | ||
18 | -@app.route('/submit', methods=['POST']) | 18 | +@app.route('/verify', methods=['POST']) |
19 | -def submit(): | 19 | +def verify(): |
20 | - image = request.args.get('image') | 20 | + image = request.form['image'] |
21 | - print(type(image)) | 21 | + data = request.form['data'] |
22 | + return jsonify(test) | ||
23 | + #recv = verify_face(image) | ||
24 | + #return recv | ||
25 | + | ... | ... |
... | @@ -6,8 +6,8 @@ | ... | @@ -6,8 +6,8 @@ |
6 | <style> | 6 | <style> |
7 | #container { | 7 | #container { |
8 | margin: 0px auto; | 8 | margin: 0px auto; |
9 | - width: 1280px; | 9 | + width: 640px; |
10 | - height: 1280px; | 10 | + height: 480px; |
11 | border: 10px #333 solid; | 11 | border: 10px #333 solid; |
12 | } | 12 | } |
13 | #videoInput { | 13 | #videoInput { |
... | @@ -19,6 +19,7 @@ | ... | @@ -19,6 +19,7 @@ |
19 | </style> | 19 | </style> |
20 | <script type='text/javascript' src="{{url_for('static', filename='js/opencv.js')}}"></script> | 20 | <script type='text/javascript' src="{{url_for('static', filename='js/opencv.js')}}"></script> |
21 | <script type='text/javascript' src="{{url_for('static', filename='js/utils.js')}}"></script> | 21 | <script type='text/javascript' src="{{url_for('static', filename='js/utils.js')}}"></script> |
22 | +<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> | ||
22 | <script type='text/javascript'> | 23 | <script type='text/javascript'> |
23 | function load_cascade() | 24 | function load_cascade() |
24 | { | 25 | { |
... | @@ -86,14 +87,13 @@ function processVideo() { | ... | @@ -86,14 +87,13 @@ function processVideo() { |
86 | cropped = src.roi(rect); | 87 | cropped = src.roi(rect); |
87 | let tempCanvas = document.createElement("canvas"); | 88 | let tempCanvas = document.createElement("canvas"); |
88 | cv.imshow(tempCanvas,cropped); | 89 | cv.imshow(tempCanvas,cropped); |
89 | - let b64encoded = tempCanvas.toDataURL('image/jpeg', 1.0); | 90 | + let b64encoded = tempCanvas.toDataURL("image/jpeg", 1.0); |
90 | - var msg = { | 91 | + $.ajax({ |
91 | - action: "verify", | 92 | + type: "POST", |
92 | - img: b64encoded, | 93 | + url: "{{url_for('verify')}}", |
93 | - date: Date.now() | 94 | + dataType: "json", |
94 | - }; | 95 | + data: {'image':b64encoded, 'data':'testestest'} |
95 | - let socket = new WebSocket("ws://13.124.104.70:3000"); | 96 | + }); |
96 | - socket.send(JSON.stringify(msg)); | ||
97 | } | 97 | } |
98 | cv.imshow('canvasOutput', dst); | 98 | cv.imshow('canvasOutput', dst); |
99 | // schedule the next one. | 99 | // schedule the next one. |
... | @@ -111,6 +111,7 @@ setTimeout(processVideo, 0); | ... | @@ -111,6 +111,7 @@ setTimeout(processVideo, 0); |
111 | <div id="container"> | 111 | <div id="container"> |
112 | <video autoplay="true" id="videoInput" width=640 height=480 style="display: none;"></video> | 112 | <video autoplay="true" id="videoInput" width=640 height=480 style="display: none;"></video> |
113 | <canvas id="canvasOutput" width=640 height=480></canvas> | 113 | <canvas id="canvasOutput" width=640 height=480></canvas> |
114 | +<div id="hidden_container" style="display: none;"><div> | ||
114 | </div> | 115 | </div> |
115 | </body> | 116 | </body> |
116 | </html> | 117 | </html> | ... | ... |
-
Please register or login to post a comment