From cc1afabe84d81e884032b72f2e5cc127590a00c8 Mon Sep 17 00:00:00 2001 From: AmyangXYZ Date: Tue, 24 Sep 2024 17:19:17 -0400 Subject: [PATCH] force refresh task for image detection --- src/Video.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Video.tsx b/src/Video.tsx index 9f33277..60a6cb1 100644 --- a/src/Video.tsx +++ b/src/Video.tsx @@ -88,15 +88,11 @@ function Video({ } setLastMedia("VIDEO") } else if (file.type.includes("image")) { - if (lastMedia === "VIDEO") { - setLerpFactor(1) - holisticLandmarkerRef.current?.setOptions({ runningMode: "IMAGE" }).then(() => { - setVideoSrc("") - setImgSrc(url) - }) - } else { + setLerpFactor(1) + holisticLandmarkerRef.current?.setOptions({ runningMode: "IMAGE" }).then(() => { + setVideoSrc("") setImgSrc(url) - } + }) setLastMedia("IMAGE") } } @@ -235,10 +231,12 @@ function Video({ imgRef.current && imgRef.current.src.length > 0 && imgRef.current.src != lastImgSrc && - imgRef.current.complete + imgRef.current.complete && + imgRef.current.naturalWidth > 0 ) { lastImgSrc = imgRef.current.src - holisticLandmarkerRef.current!.detect(imgRef.current, (result) => { + + holisticLandmarkerRef.current!.detect(imgRef.current!, (result) => { if (result.poseWorldLandmarks[0]) { setPose(result.poseWorldLandmarks[0]) } else {