Unverified Commit bc6014d5 by justadudewhohacks Committed by GitHub

Merge pull request #24 from justadudewhohacks/#21

wait for model being loaded before processing video frames
parents c9a1e5f7 6e39666b
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<div class="indeterminate"></div> <div class="indeterminate"></div>
</div> </div>
<div style="position: relative" class="margin"> <div style="position: relative" class="margin">
<video src="media/bbt.mp4" onplay="onPlay(this)" autoplay muted></video> <video src="media/bbt.mp4" onplay="onPlay(this)" id="inputVideo" autoplay muted></video>
<canvas id="overlay" /> <canvas id="overlay" />
</div> </div>
<div class="row side-by-side"> <div class="row side-by-side">
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
<script> <script>
let minConfidence = 0.7 let minConfidence = 0.7
let modelLoaded = false
let result let result
function onIncreaseThreshold() { function onIncreaseThreshold() {
...@@ -68,7 +69,7 @@ ...@@ -68,7 +69,7 @@
} }
async function onPlay(videoEl) { async function onPlay(videoEl) {
if(videoEl.paused || videoEl.ended) if(videoEl.paused || videoEl.ended || !modelLoaded)
return false return false
const input = await faceapi.toNetInput(videoEl) const input = await faceapi.toNetInput(videoEl)
...@@ -87,6 +88,8 @@ ...@@ -87,6 +88,8 @@
async function run() { async function run() {
await faceapi.loadFaceDetectionModel('/') await faceapi.loadFaceDetectionModel('/')
modelLoaded = true
onPlay($('#inputVideo').get(0))
$('#loader').hide() $('#loader').hide()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment