Graduate

Opencv.js face detection

......@@ -22,17 +22,18 @@
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()
{
......@@ -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"-->
......