Skip to content

Commit

Permalink
refactor: use state var instead of javascript var for predicting
Browse files Browse the repository at this point in the history
  • Loading branch information
Lena Ebner committed Dec 15, 2023
1 parent 69fd92e commit 2e6ce48
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions robot_ui/src/utils/useDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ export const useFaceLandmarkDetector = (): FaceLandmarkDetectorType => {

const startPrediction = () => {
console.log('startPrediction');
predictionRunning = true;
setIsPredicting(true);
smileDegrees = Array(100).fill(0);
currentMaxSmileDegree = 0;
Expand All @@ -244,7 +243,6 @@ export const useFaceLandmarkDetector = (): FaceLandmarkDetectorType => {
if (!faceLandmarkerService.faceLandmarker || !video) return;

console.log('final max smile degree predicted', currentMaxSmileDegree);
predictionRunning = false;
setIsPredicting(false);
setMaxSmileDegree(currentMaxSmileDegree);
clearInterval(predictionIntervalRef.current);
Expand All @@ -253,8 +251,8 @@ export const useFaceLandmarkDetector = (): FaceLandmarkDetectorType => {
};

const predictWebcam = useCallback(() => {
console.log('predictWebcam', faceLandmarkerService.faceLandmarker, video, predictionRunning);
if (!predictionRunning) return;
// console.log('predictWebcam', faceLandmarkerService.faceLandmarker, video, predictionRunning);
if (!isPredicting) return;

if (!faceLandmarkerService.faceLandmarker || !video) return;
let startTimeMs = performance.now();
Expand Down

0 comments on commit 2e6ce48

Please sign in to comment.