정지호

Update sound

No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 -<html lang="en"> 2 +<html lang="ko">
3 <head> 3 <head>
4 <meta charset="UTF-8"> 4 <meta charset="UTF-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 - <title>Squart Page</title> 7 + <link rel="stylesheet" href="style.css">
8 + <title>Squat Page</title>
8 </head> 9 </head>
9 <body> 10 <body>
10 - <div>Teachable Machine Pose Model - Squart</div> 11 + <h1><div>Teachable Machine Pose Model - Squat</div></h1>
11 <button type="button" onclick="init()">Start</button> 12 <button type="button" onclick="init()">Start</button>
12 <div><canvas id="canvas"></canvas></div> 13 <div><canvas id="canvas"></canvas></div>
13 <div id="label-container"></div> 14 <div id="label-container"></div>
...@@ -51,7 +52,8 @@ ...@@ -51,7 +52,8 @@
51 await predict(); 52 await predict();
52 window.requestAnimationFrame(loop); 53 window.requestAnimationFrame(loop);
53 } 54 }
54 - // 상태 55 +
56 + // 상태 : 서있는 상태로 초기화
55 let status = "stand" ; 57 let status = "stand" ;
56 // 갯수 count 58 // 갯수 count
57 let count = 0; 59 let count = 0;
...@@ -63,25 +65,22 @@ ...@@ -63,25 +65,22 @@
63 // Prediction 2: run input through teachable machine classification model 65 // Prediction 2: run input through teachable machine classification model
64 const prediction = await model.predict(posenetOutput); 66 const prediction = await model.predict(posenetOutput);
65 67
66 - if (prediction[0].probability.toFixed(2) > 0.9) // 서있는 상태 68 + if (prediction[0].probability.toFixed(2) > 0.9) { // 서있는 상태
67 - { 69 + if (status == "squat"){ // 전에 스쿼트 상태였다면, 일어날 때 카운트를 하나 올려줘야 함.
68 - if (status == "squart")
69 - {
70 count++; 70 count++;
71 + var audio = new Audio(count%10 + '.wav');
72 + audio.play();
73 + console.log(count);
71 } 74 }
72 - status = "stand"; 75 + status = "stand"
73 - } 76 + } else if (prediction[1].probability.toFixed(2) == 1.00) { // 스쿼트 자세
74 - else if (prediction[1].probability.toFixed(2) == 1.00) // 스쿼트 자세 77 + status = "squat"
75 - { 78 + } else if (prediction[2].probability.toFixed(2) == 1.00) { // 굽은 자세(잘못된 케이스)
76 - status = "squart"; 79 + if (status == "squart" || status == "stand") { // 굽은 자세로 잘못 수행하면, 소리 나도록
77 - } 80 + var audio = new Audio('bad.mp3');
78 - else if (prediction[2].probability.toFixed(2) == 1.00) // 굽은 자세(잘못된 케이스) 81 + audio.play();
79 - {
80 - if (status == "squart" || status == "stand") // 굽은 자세로 잘못 수행하면,
81 - {
82 - console.log("잘못된 경우 입니다.")
83 } 82 }
84 - status = "bent"; 83 + status = "bent"
85 } 84 }
86 85
87 for (let i = 0; i < maxPredictions; i++) { 86 for (let i = 0; i < maxPredictions; i++) {
......
1 +h1 {
2 + font-family: 'Lobster';
3 +}