Showing
4 changed files
with
94 additions
and
4 deletions
... | @@ -47,7 +47,39 @@ app.get('/', (req,res) => { | ... | @@ -47,7 +47,39 @@ app.get('/', (req,res) => { |
47 | }) | 47 | }) |
48 | 48 | ||
49 | // 음성 소리 파일 전송 | 49 | // 음성 소리 파일 전송 |
50 | - | 50 | +app.get('/sound/0.wav', (req,res) => { |
51 | + res.sendFile(__dirname + '/views/squatPage/sound/0.wav') | ||
52 | +}) | ||
53 | +app.get('/sound/1.wav', (req,res) => { | ||
54 | + res.sendFile(__dirname + '/views/squatPage/sound/1.wav') | ||
55 | +}) | ||
56 | +app.get('/sound/2.wav', (req,res) => { | ||
57 | + res.sendFile(__dirname + '/views/squatPage/sound/2.wav') | ||
58 | +}) | ||
59 | +app.get('/sound/3.wav', (req,res) => { | ||
60 | + res.sendFile(__dirname + '/views/squatPage/sound/3.wav') | ||
61 | +}) | ||
62 | +app.get('/sound/4.wav', (req,res) => { | ||
63 | + res.sendFile(__dirname + '/views/squatPage/sound/4.wav') | ||
64 | +}) | ||
65 | +app.get('/sound/5.wav', (req,res) => { | ||
66 | + res.sendFile(__dirname + '/views/squatPage/sound/5.wav') | ||
67 | +}) | ||
68 | +app.get('/sound/6.wav', (req,res) => { | ||
69 | + res.sendFile(__dirname + '/views/squatPage/sound/6.wav') | ||
70 | +}) | ||
71 | +app.get('/sound/7.wav', (req,res) => { | ||
72 | + res.sendFile(__dirname + '/views/squatPage/sound/7.wav') | ||
73 | +}) | ||
74 | +app.get('/sound/8.wav', (req,res) => { | ||
75 | + res.sendFile(__dirname + '/views/squatPage/sound/8.wav') | ||
76 | +}) | ||
77 | +app.get('/sound/9.wav', (req,res) => { | ||
78 | + res.sendFile(__dirname + '/views/squatPage/sound/9.wav') | ||
79 | +}) | ||
80 | +app.get('/sound/bad.mp3', (req,res) => { | ||
81 | + res.sendFile(__dirname + '/views/squatPage/sound/bad.mp3') | ||
82 | +}) | ||
51 | 83 | ||
52 | 84 | ||
53 | 85 | ||
... | @@ -175,6 +207,13 @@ app.get('/api/users/logout', (req,res) => { | ... | @@ -175,6 +207,13 @@ app.get('/api/users/logout', (req,res) => { |
175 | 207 | ||
176 | }) | 208 | }) |
177 | 209 | ||
210 | +app.get('/api/users/name', (req,res) => { | ||
211 | + return res.json({ | ||
212 | + user : req.session.user | ||
213 | + }) | ||
214 | +}) | ||
215 | + | ||
216 | + | ||
178 | // 스쿼트 갯수 업데이트 API | 217 | // 스쿼트 갯수 업데이트 API |
179 | app.post('/api/users/countupdate', (req,res) => { | 218 | app.post('/api/users/countupdate', (req,res) => { |
180 | var userName = req.body.name | 219 | var userName = req.body.name | ... | ... |
... | @@ -6,12 +6,15 @@ | ... | @@ -6,12 +6,15 @@ |
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 | <link rel="stylesheet" href="squat.css"> | 7 | <link rel="stylesheet" href="squat.css"> |
8 | <title>Squat Page</title> | 8 | <title>Squat Page</title> |
9 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | ||
9 | </head> | 10 | </head> |
10 | <body bgcolor= "#353535"> | 11 | <body bgcolor= "#353535"> |
11 | <div id="title" class="Title"> | 12 | <div id="title" class="Title"> |
12 | Squat Page | 13 | Squat Page |
14 | + | ||
13 | <center> | 15 | <center> |
14 | <button class="w-btn w-btn-indigo" type="button" onclick="init()">WEBCAM START</button> | 16 | <button class="w-btn w-btn-indigo" type="button" onclick="init()">WEBCAM START</button> |
17 | + <button id = "savecount" class="w-btn w-btn-indigo" type="button" onclick="">스쿼트 횟수 저장</button> | ||
15 | <div> | 18 | <div> |
16 | <canvas id="canvas"></canvas> | 19 | <canvas id="canvas"></canvas> |
17 | <iframe | 20 | <iframe |
... | @@ -28,6 +31,7 @@ | ... | @@ -28,6 +31,7 @@ |
28 | </center> | 31 | </center> |
29 | </div> | 32 | </div> |
30 | <div id="label-container" class="label-container"></div> | 33 | <div id="label-container" class="label-container"></div> |
34 | + | ||
31 | <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.3.1/dist/tf.min.js"></script> | 35 | <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.3.1/dist/tf.min.js"></script> |
32 | <script src="https://cdn.jsdelivr.net/npm/@teachablemachine/pose@0.8/dist/teachablemachine-pose.min.js"></script> | 36 | <script src="https://cdn.jsdelivr.net/npm/@teachablemachine/pose@0.8/dist/teachablemachine-pose.min.js"></script> |
33 | <script src="./squat.js"></script> | 37 | <script src="./squat.js"></script> | ... | ... |
1 | // More API functions here: | 1 | // More API functions here: |
2 | // https://github.com/googlecreativelab/teachablemachine-community/tree/master/libraries/pose | 2 | // https://github.com/googlecreativelab/teachablemachine-community/tree/master/libraries/pose |
3 | + | ||
3 | // the link to your model provided by Teachable Machine export panel | 4 | // the link to your model provided by Teachable Machine export panel |
4 | const URL = "https://teachablemachine.withgoogle.com/models/xymjZj4q-/"; // 임시 URI - stand , squart, bent(허리 굽은 자세) 학습. | 5 | const URL = "https://teachablemachine.withgoogle.com/models/xymjZj4q-/"; // 임시 URI - stand , squart, bent(허리 굽은 자세) 학습. |
5 | let model, webcam, ctx, labelContainer, maxPredictions; | 6 | let model, webcam, ctx, labelContainer, maxPredictions; |
6 | 7 | ||
7 | -// 상태 : 서있는 상태로 초기화 | 8 | + |
8 | -let status = "stand" ; | ||
9 | // 갯수 count | 9 | // 갯수 count |
10 | let count = 0; | 10 | let count = 0; |
11 | var counter = document.getElementById("counter"); | 11 | var counter = document.getElementById("counter"); |
... | @@ -100,3 +100,51 @@ function drawPose(pose) { | ... | @@ -100,3 +100,51 @@ function drawPose(pose) { |
100 | } | 100 | } |
101 | } | 101 | } |
102 | } | 102 | } |
103 | + | ||
104 | + | ||
105 | +// 사용자 정보 API | ||
106 | + | ||
107 | +let userName = 0 | ||
108 | + | ||
109 | +$.get('/api/users/name', function(data) { | ||
110 | + userName = data.user.user_name | ||
111 | + console.log(data.user.user_name) | ||
112 | +}) | ||
113 | +$(document).ready(function(){ | ||
114 | + $('#savecount').click(function(){ | ||
115 | + | ||
116 | + | ||
117 | + $.ajax({ | ||
118 | + contentType : "application/json; charset=utf-8", | ||
119 | + type : 'get', | ||
120 | + url : '/api/users/name', | ||
121 | + dataType : 'JSON', | ||
122 | + | ||
123 | + success : function(datas) { | ||
124 | + | ||
125 | + let user_name = datas.user_name | ||
126 | + $.ajax({ | ||
127 | + contentType : "application/json; charset=utf-8", | ||
128 | + type : 'post', | ||
129 | + url : '/api/users/countupdate', | ||
130 | + dataType : 'JSON', | ||
131 | + data : JSON.stringify({ | ||
132 | + "name" : userName, | ||
133 | + "count" : count | ||
134 | + }), | ||
135 | + | ||
136 | + success : function(datas) | ||
137 | + { | ||
138 | + if (datas.success) | ||
139 | + { | ||
140 | + alert("저장 성공 !") | ||
141 | + } | ||
142 | + } | ||
143 | + }) | ||
144 | + } | ||
145 | + }) | ||
146 | + }) | ||
147 | +}) | ||
148 | + | ||
149 | + | ||
150 | + | ... | ... |
healthcare-with-webcam @ 381096f7
1 | -Subproject commit 381096f776f0756063d2f9e77ceaca7d5fc7fcdc |
-
Please register or login to post a comment