Toggle navigation
Toggle navigation
This project
Loading...
Sign in
공태현
/
healthcare-with-webcam
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
공태현
2022-06-08 18:37:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5b3923440f4580ea170dce28eda72c5c2dd5bc9b
5b392344
1 parent
4b6bf184
Change Model URL and update CSS (JIHO)
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
views/squatPage/squat.css
views/squatPage/squat.js
views/squatPage/squat.css
View file @
5b39234
@import
url('https://fonts.googleapis.com/css2?family=Nanum+Pen+Script&display=swap')
;
@import
url("https://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700,800,900&display=swap")
;
@font-face
{
font-family
:
'BMJUA'
;
src
:
url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_one@1.0/BMJUA.woff')
format
(
'woff'
);
font-weight
:
normal
;
font-style
:
normal
;
}
@font-face
{
font-family
:
'BMEULJIRO'
;
src
:
url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_twelve@1.0/BMEULJIRO.woff')
format
(
'woff'
);
font-weight
:
normal
;
font-style
:
normal
;
}
button
{
margin
:
10px
;
...
...
@@ -11,7 +25,7 @@ button {
display
:
inline-block
;
padding
:
15px
30px
;
border-radius
:
15px
;
font-family
:
"
paybooc-Light
"
,
sans-serif
;
font-family
:
"
BMJUA
"
,
sans-serif
;
box-shadow
:
0
15px
35px
rgba
(
0
,
0
,
0
,
0.2
);
text-decoration
:
none
;
font-weight
:
600
;
...
...
@@ -22,7 +36,7 @@ button {
position
:
relative
;
padding
:
15px
30px
;
border-radius
:
15px
;
font-family
:
"
paybooc-Light
"
,
sans-serif
;
font-family
:
"
BMJUA
"
,
sans-serif
;
box-shadow
:
0
15px
35px
rgba
(
0
,
0
,
0
,
0.2
);
text-decoration
:
none
;
font-weight
:
600
;
...
...
@@ -46,7 +60,7 @@ button {
.Title
{
font-size
:
100px
;
font-family
:
fantasy
;
font-family
:
BMEULJIRO
;
color
:
aliceblue
;
margin-top
:
15%
;
text-align
:
center
;
...
...
@@ -54,7 +68,7 @@ button {
.click_title
{
font-size
:
40px
;
font-family
:
fantasy
;
font-family
:
BMEULJIRO
;
color
:
aliceblue
;
margin-top
:
40px
;
margin-bottom
:
20px
;
...
...
views/squatPage/squat.js
View file @
5b39234
...
...
@@ -2,12 +2,12 @@
// https://github.com/googlecreativelab/teachablemachine-community/tree/master/libraries/pose
// the link to your model provided by Teachable Machine export panel
const
URL
=
"https://teachablemachine.withgoogle.com/models/
xymjZj4q-
/"
;
// 임시 URI - stand , squart, bent(허리 굽은 자세) 학습.
const
URL
=
"https://teachablemachine.withgoogle.com/models/
J8-G4eWbz
/"
;
// 임시 URI - stand , squart, bent(허리 굽은 자세) 학습.
let
model
,
webcam
,
ctx
,
labelContainer
,
maxPredictions
;
// 갯수 count
let
count
=
0
;
var
count
=
0
;
var
counter
=
document
.
getElementById
(
"counter"
);
counter
.
textContent
=
count
;
counter
.
className
=
"hidden"
;
...
...
@@ -52,6 +52,7 @@ async function loop(timestamp) {
await
predict
();
window
.
requestAnimationFrame
(
loop
);
}
var
status
=
"stand"
;
async
function
predict
()
{
// Prediction #1: run input through posenet
...
...
@@ -59,24 +60,28 @@ async function predict() {
const
{
pose
,
posenetOutput
}
=
await
model
.
estimatePose
(
webcam
.
canvas
);
// Prediction 2: run input through teachable machine classification model
const
prediction
=
await
model
.
predict
(
posenetOutput
);
let
status
=
"stand"
if
(
prediction
[
0
].
probability
.
toFixed
(
2
)
>
0.9
)
{
// 서있는 상태
if
(
status
==
"squat"
){
// 전에 스쿼트 상태였다면, 일어날 때 카운트를 하나 올려줘야 함.
count
++
;
var
audio
=
new
Audio
(
'./sound/'
+
count
%
10
+
'.wav'
);
audio
.
play
();
counter
.
textContent
=
count
;
console
.
log
(
count
);
}
status
=
"stand"
}
else
if
(
prediction
[
1
].
probability
.
toFixed
(
2
)
==
1.00
)
{
// 스쿼트 자세
status
=
"squat"
}
else
if
(
prediction
[
2
].
probability
.
toFixed
(
2
)
==
1.00
)
{
// 굽은 자세(잘못된 케이스)
if
(
status
==
"squa
r
t"
||
status
==
"stand"
)
{
// 굽은 자세로 잘못 수행하면, 소리 나도록
if
(
status
==
"squat"
||
status
==
"stand"
)
{
// 굽은 자세로 잘못 수행하면, 소리 나도록
var
audio
=
new
Audio
(
'./sound/bad.mp3'
);
audio
.
play
();
}
status
=
"bent"
console
.
log
(
status
);
}
for
(
let
i
=
0
;
i
<
maxPredictions
;
i
++
)
{
...
...
Please
register
or
login
to post a comment