Showing
1 changed file
with
3 additions
and
4 deletions
... | @@ -29,9 +29,8 @@ function activate() | ... | @@ -29,9 +29,8 @@ function activate() |
29 | function detect_face() | 29 | function detect_face() |
30 | { | 30 | { |
31 | let classifier = new cv.CascadeClassifier(); | 31 | let classifier = new cv.CascadeClassifier(); |
32 | - let imgElement = document.getElementById('imagefile'); | ||
33 | classifier.load('haarcascade_frontalface_default.xml'); | 32 | classifier.load('haarcascade_frontalface_default.xml'); |
34 | - let src = cv.imread(imgElement); | 33 | + let src = cv.imread('imagefile'); |
35 | let dst = new cv.Mat(video.height, video.width, cv.CV_8UC4); | 34 | let dst = new cv.Mat(video.height, video.width, cv.CV_8UC4); |
36 | let gray = new cv.Mat(); | 35 | let gray = new cv.Mat(); |
37 | src.copyTo(dst); | 36 | src.copyTo(dst); |
... | @@ -93,9 +92,9 @@ var loadFile = function(event) { | ... | @@ -93,9 +92,9 @@ var loadFile = function(event) { |
93 | reader.readAsDataURL(event.target.files[0]); | 92 | reader.readAsDataURL(event.target.files[0]); |
94 | reader.onload = function() { | 93 | reader.onload = function() { |
95 | var output = document.getElementById('imagefile'); | 94 | var output = document.getElementById('imagefile'); |
96 | - output.src = URL.createObjectURL(event.target.files[0]); | 95 | + output.src = reader.result; |
97 | detect_face(); | 96 | detect_face(); |
98 | - } | 97 | + }; |
99 | }; | 98 | }; |
100 | 99 | ||
101 | let tempCanvas = document.createElement("canvas"); | 100 | let tempCanvas = document.createElement("canvas"); | ... | ... |
-
Please register or login to post a comment