Skip to content

Commit

Permalink
[FIX] Only run face detection if the video element has data
Browse files Browse the repository at this point in the history
  • Loading branch information
willeastcott committed Feb 10, 2025
1 parent bcf5ec8 commit bf15d11
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/assets/scripts/face-landmarks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class FaceLandmarks extends Script {
update(dt) {
if (this.faceLandmarker) {
const video = document.querySelector('video');
if (video) {
if (video && video.readyState >= HTMLMediaElement.HAVE_ENOUGH_DATA) {
const detections = this.faceLandmarker.detectForVideo(video, Date.now());
if (detections && detections.faceBlendshapes) {
if (detections.faceBlendshapes.length > 0) {
Expand Down

0 comments on commit bf15d11

Please sign in to comment.