Skip to content

Commit

Permalink
force refresh task for image detection
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyangXYZ committed Sep 24, 2024
1 parent 3bf1ee7 commit cc1afab
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit cc1afab

Please sign in to comment.