Graduate

Opencv.js face detect

...@@ -41,6 +41,9 @@ if (navigator.mediaDevices.getUserMedia){ ...@@ -41,6 +41,9 @@ if (navigator.mediaDevices.getUserMedia){
41 } 41 }
42 </script> 42 </script>
43 <script> 43 <script>
44 +function openCvReady() {
45 + cv['onRuntimeInitialized']=()=>{
46 + // do all your work here
44 let video = document.getElementById('videoElement'); 47 let video = document.getElementById('videoElement');
45 let src = new cv.Mat(video.height, video.width, cv.CV_8UC4); 48 let src = new cv.Mat(video.height, video.width, cv.CV_8UC4);
46 let dst = new cv.Mat(video.height, video.width, cv.CV_8UC4); 49 let dst = new cv.Mat(video.height, video.width, cv.CV_8UC4);
...@@ -81,10 +84,11 @@ if (navigator.mediaDevices.getUserMedia){ ...@@ -81,10 +84,11 @@ if (navigator.mediaDevices.getUserMedia){
81 } catch (err) { 84 } catch (err) {
82 utils.printError(err); 85 utils.printError(err);
83 } 86 }
87 + // schedule the first one.
88 + setTimeout(processVideo, 0);
84 }; 89 };
85 - 90 + };
86 -// schedule the first one. 91 +}
87 -setTimeout(processVideo, 0);
88 </script> 92 </script>
89 </body> 93 </body>
90 </html> 94 </html>
......