Graduate

Opencv.js face detection

......@@ -161,4 +161,4 @@ function Utils(errorOutputId) { // eslint-disable-line no-unused-vars
this.stream.getVideoTracks()[0].stop();
}
};
};
\ No newline at end of file
};
......
......@@ -22,18 +22,19 @@
background-color: #666;
}
</style>
<script type='text/javascript' src="{{url_for('static', filename='js/opencv.js')}}"></script>
<script type='text/javascript' src="{{url_for('static', filename='js/utils.js')}}"></script>
<script type='text/javascript'>
let utils = new Utils('errorMessage');
utils.loadOpenCv(() => {
let faceCascadeFile = '/static/js/haarcascade_frontalface_default.xml';
utils.createFileFromUrl(faceCascadeFile, faceCascadeFile, () => {
alert(faceCascadeFile);
function load_cascade()
{
let faceCascadeFile = 'haarcascade_frontalface_default.xml'
let faceCascadeURL = 'static/js/haarcascade_frontalface_default.xml'
let utils = new Utils('errorMessage');
utils.createFileFromUrl(faceCascadeFile, faceCascadeURL, () => {
main()
});
});
}
function main()
{
let video = document.getElementById("videoInput");
......@@ -56,7 +57,7 @@ let faces = new cv.RectVector();
let classifier = new cv.CascadeClassifier();
var streaming = true;
classifier.load('static/js/haarcascade_frontalface_default.xml');
classifier.load('haarcascade_frontalface_default.xml');
const FPS = 30;
function processVideo() {
......@@ -99,7 +100,7 @@ setTimeout(processVideo, 0);
}
</script>
</head>
<body onload="cv['onRuntimeInitialized']=()=>{ main() }">
<body onload="cv['onRuntimeInitialized']=()=>{ load_cascade() }">
<div id="container">
<video autoplay="true" id="videoInput" width=640 height=480> <!-- style="visibility: hidden"-->
......