Skip to content

Commit

Permalink
Update demo to automatically select the first available webcam, after…
Browse files Browse the repository at this point in the history
… `tfjs` models load
  • Loading branch information
Valkryst committed Dec 7, 2023
1 parent 878a945 commit 6235985
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@
document.getElementById("hand-detector-ready").innerText = "True";
});

const warmupInterval = setInterval(async () => {
if (bodyDetector.isReady() && faceDetector.isReady() && handDetector.isReady()) {
clearInterval(warmupInterval);
(await Camera.getSelectElement()).disabled = false;
}
}, 100);

let camera = null;
let resizeTimeout = null;
const updateDisplay = async () => {
Expand Down Expand Up @@ -215,6 +208,18 @@
}
};

const warmupInterval = setInterval(async () => {
if (bodyDetector.isReady() && faceDetector.isReady() && handDetector.isReady()) {
clearInterval(warmupInterval);

deviceSelect.removeAttribute("disabled");
if (deviceSelect.length > 1) {
deviceSelect.options[1].setAttribute("selected", "");
deviceSelect.onchange();
}
}
}, 100);

const bodyDetectorStats = new StatRecorder(30);
bodyDetector.addEventListener("updated", e => {
bodyDetectorStats.record(e.detail.runtime);
Expand Down

0 comments on commit 6235985

Please sign in to comment.