Graduate

Update flask

...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
11 <script type='text/javascript' src="{{url_for('static', filename='js/utils.js')}}"></script> 11 <script type='text/javascript' src="{{url_for('static', filename='js/utils.js')}}"></script>
12 <script type='text/javascript' src="https://code.jquery.com/jquery-1.12.4.min.js"></script> 12 <script type='text/javascript' src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
13 <script type='text/javascript'> 13 <script type='text/javascript'>
14 -let tempCanvas = document.createElement("canvas"); 14 +var tempImage = new Image();
15 +var tempCanvas = document.createElement("canvas");
16 +
15 function load_cascade() 17 function load_cascade()
16 { 18 {
17 let faceCascadeFile = 'haarcascade_frontalface_default.xml' 19 let faceCascadeFile = 'haarcascade_frontalface_default.xml'
...@@ -27,11 +29,11 @@ function activate() ...@@ -27,11 +29,11 @@ function activate()
27 fileloader.disabled = false; 29 fileloader.disabled = false;
28 } 30 }
29 31
30 -function detect_face(img) 32 +function detect_face()
31 { 33 {
32 let canvas = document.createElement('canvas'); 34 let canvas = document.createElement('canvas');
33 let ctx = canvas.getContext('2d') 35 let ctx = canvas.getContext('2d')
34 - ctx.src = img; 36 + ctx.drawImage(tempImage, 0, 0);
35 let src = cv.imread(canvas); 37 let src = cv.imread(canvas);
36 let dst = new cv.Mat(src.cols, src.rows, cv.CV_8UC4); 38 let dst = new cv.Mat(src.cols, src.rows, cv.CV_8UC4);
37 let gray = new cv.Mat(); 39 let gray = new cv.Mat();
...@@ -98,8 +100,8 @@ var loadFile = function(event) { ...@@ -98,8 +100,8 @@ var loadFile = function(event) {
98 var reader = new FileReader(); 100 var reader = new FileReader();
99 reader.readAsDataURL(event.target.files[0]); 101 reader.readAsDataURL(event.target.files[0]);
100 reader.onload = function() { 102 reader.onload = function() {
101 - let img = reader.result; 103 + tempImage.src = reader.result;
102 - detect_face(img); 104 + detect_face();
103 }; 105 };
104 }; 106 };
105 </script> 107 </script>
......