Graduate

Make image from detected roi

......@@ -76,11 +76,17 @@ function processVideo() {
let msize = new cv.Size(120, 120);
classifier.detectMultiScale(gray, faces, 1.1, 3, 0, msize);
// draw faces.
var images = new Array();
for (let i = 0; i < faces.size(); ++i) {
let face = faces.get(i);
let point1 = new cv.Point(face.x, face.y);
let point2 = new cv.Point(face.x + face.width, face.y + face.height);
let rect = cv.Rect(face.x, face.y, face.x + face.width, face.y + face.height)
cv.rectangle(dst, point1, point2, [255, 0, 0, 255]);
let roi = src.roi(rect);
let img = cv.imencode('jpg', roi).toString('base64');
alert(img);
images.append(img);
}
cv.imshow('canvasOutput', dst);
// schedule the next one.
......@@ -96,12 +102,8 @@ setTimeout(processVideo, 0);
</head>
<body onload="cv['onRuntimeInitialized']=()=>{ load_cascade() }">
<div id="container">
<canvas id="canvasOutput" width=640 height=480></canvas>
</div>
<video autoplay="true" id="videoInput" width=640 height=480 style="display: none;">
</video>
<canvas id='canvasOutput' width=640 height=480>
</canvas>
</div>
</body>
</html>
......