Showing
1 changed file
with
8 additions
and
6 deletions
... | @@ -76,11 +76,17 @@ function processVideo() { | ... | @@ -76,11 +76,17 @@ function processVideo() { |
76 | let msize = new cv.Size(120, 120); | 76 | let msize = new cv.Size(120, 120); |
77 | classifier.detectMultiScale(gray, faces, 1.1, 3, 0, msize); | 77 | classifier.detectMultiScale(gray, faces, 1.1, 3, 0, msize); |
78 | // draw faces. | 78 | // draw faces. |
79 | + var images = new Array(); | ||
79 | for (let i = 0; i < faces.size(); ++i) { | 80 | for (let i = 0; i < faces.size(); ++i) { |
80 | let face = faces.get(i); | 81 | let face = faces.get(i); |
81 | let point1 = new cv.Point(face.x, face.y); | 82 | let point1 = new cv.Point(face.x, face.y); |
82 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); | 83 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); |
84 | + let rect = cv.Rect(face.x, face.y, face.x + face.width, face.y + face.height) | ||
83 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255]); | 85 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255]); |
86 | + let roi = src.roi(rect); | ||
87 | + let img = cv.imencode('jpg', roi).toString('base64'); | ||
88 | + alert(img); | ||
89 | + images.append(img); | ||
84 | } | 90 | } |
85 | cv.imshow('canvasOutput', dst); | 91 | cv.imshow('canvasOutput', dst); |
86 | // schedule the next one. | 92 | // schedule the next one. |
... | @@ -96,12 +102,8 @@ setTimeout(processVideo, 0); | ... | @@ -96,12 +102,8 @@ setTimeout(processVideo, 0); |
96 | </head> | 102 | </head> |
97 | <body onload="cv['onRuntimeInitialized']=()=>{ load_cascade() }"> | 103 | <body onload="cv['onRuntimeInitialized']=()=>{ load_cascade() }"> |
98 | <div id="container"> | 104 | <div id="container"> |
105 | +<canvas id="canvasOutput" width=640 height=480></canvas> | ||
106 | +</div> | ||
99 | <video autoplay="true" id="videoInput" width=640 height=480 style="display: none;"> | 107 | <video autoplay="true" id="videoInput" width=640 height=480 style="display: none;"> |
100 | - | ||
101 | </video> | 108 | </video> |
102 | -<canvas id='canvasOutput' width=640 height=480> | ||
103 | - | ||
104 | -</canvas> | ||
105 | -</div> | ||
106 | -</body> | ||
107 | </html> | 109 | </html> | ... | ... |
-
Please register or login to post a comment