공태현

Count sqaurt good case and wrong case

...@@ -54,6 +54,10 @@ ...@@ -54,6 +54,10 @@
54 await predict(); 54 await predict();
55 window.requestAnimationFrame(loop); 55 window.requestAnimationFrame(loop);
56 } 56 }
57 + // 상태
58 + let status = "stand" ;
59 + // 갯수 count
60 + let count = 0;
57 61
58 async function predict() { 62 async function predict() {
59 // Prediction #1: run input through posenet 63 // Prediction #1: run input through posenet
...@@ -62,6 +66,27 @@ ...@@ -62,6 +66,27 @@
62 // Prediction 2: run input through teachable machine classification model 66 // Prediction 2: run input through teachable machine classification model
63 const prediction = await model.predict(posenetOutput); 67 const prediction = await model.predict(posenetOutput);
64 68
69 + if (prediction[0].probability.toFixed(2) > 0.9) // 서있는 상태
70 + {
71 + if (status == "squart")
72 + {
73 + count++;
74 + }
75 + status = "stand";
76 + }
77 + else if (prediction[1].probability.toFixed(2) == 1.00) // 스쿼트 자세
78 + {
79 + status = "squart";
80 + }
81 + else if (prediction[2].probability.toFixed(2) == 1.00) // 굽은 자세(잘못된 케이스)
82 + {
83 + if (status == "squart" || status == "stand") // 굽은 자세로 잘못 수행하면,
84 + {
85 + console.log("잘못된 경우 입니다.")
86 + }
87 + status = "bent";
88 + }
89 +
65 for (let i = 0; i < maxPredictions; i++) { 90 for (let i = 0; i < maxPredictions; i++) {
66 const classPrediction = 91 const classPrediction =
67 prediction[i].className + ": " + prediction[i].probability.toFixed(2); 92 prediction[i].className + ": " + prediction[i].probability.toFixed(2);
......