Skip to content

Commit

Permalink
Check we have a valid video
Browse files Browse the repository at this point in the history
  • Loading branch information
willeastcott committed Feb 10, 2025
1 parent 66b02aa commit 5c045ed
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions examples/assets/scripts/face-landmarks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ export class FaceLandmarks extends Script {
update(dt) {
if (this.faceLandmarker) {
const video = document.querySelector('video');
const detections = this.faceLandmarker.detectForVideo(video, Date.now());
if (detections && detections.faceBlendshapes) {
if (detections.faceBlendshapes.length > 0) {
const { categories } = detections.faceBlendshapes[0];
this.app.fire('face:blendshapes', categories);
if (video && video.width > 0 && video.height > 0) {
const detections = this.faceLandmarker.detectForVideo(video, Date.now());
if (detections && detections.faceBlendshapes) {
if (detections.faceBlendshapes.length > 0) {
const { categories } = detections.faceBlendshapes[0];
this.app.fire('face:blendshapes', categories);
}
}
}
}
Expand Down

0 comments on commit 5c045ed

Please sign in to comment.