Graduate

Complete opencv.js face detection

......@@ -8,7 +8,7 @@
#container {
margin: 0px auto;
width: 640px;
height: 960px;
height: 480px;
border: 10px #333 solid;
}
#videoInput {
......@@ -76,10 +76,9 @@ function processVideo() {
cap.read(src);
src.copyTo(dst);
cv.cvtColor(dst, gray, cv.COLOR_RGBA2GRAY, 0);
alert('d');
// detect faces.
classifier.detectMultiScale(gray, faces, 1.1, 3, 0);
alert('e');
let msize = new cv.Size(120, 120);
classifier.detectMultiScale(gray, faces, 1.1, 3, 0, msize);
// draw faces.
for (let i = 0; i < faces.size(); ++i) {
let face = faces.get(i);
......@@ -87,7 +86,6 @@ function processVideo() {
let point2 = new cv.Point(face.x + face.width, face.y + face.height);
cv.rectangle(dst, point1, point2, [255, 0, 0, 255]);
}
alert('f');
cv.imshow('canvasOutput', dst);
// schedule the next one.
let delay = 1000/FPS - (Date.now() - begin);
......@@ -102,7 +100,7 @@ setTimeout(processVideo, 0);
</head>
<body onload="cv['onRuntimeInitialized']=()=>{ load_cascade() }">
<div id="container">
<video autoplay="true" id="videoInput" width=640 height=480> <!-- style="visibility: hidden"-->
<video autoplay="true" id="videoInput" width=640 height=480 style="display: none">
</video>
<canvas id='canvasOutput' width=640 height=480>
......