Toggle navigation
Toggle navigation
This project
Loading...
Sign in
한우준
/
Straight-Up
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
MrMirror21
2020-12-09 17:53:35 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
39b1dab069dc971a7932010eaf8e15f92b0355e9
39b1dab0
1 parent
f6bbedb4
correct typo
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
166 deletions
straight-up/.eslintcache
straight-up/package-lock.json
straight-up/package.json
straight-up/src/AnalysisPose.js
straight-up/src/Functions.js
straight-up/src/Main.js
straight-up/.eslintcache
View file @
39b1dab
[{"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\reportWebVitals.js":"1","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\Landing.js":"2","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\components\\Header.js":"3","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\index.js":"4","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\components\\Button.js":"5","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\App.js":"6","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\Main.js":"7"},{"size":362,"mtime":1606827597211,"results":"8","hashOfConfig":"9"},{"size":0,"mtime":1607082038941,"results":"10","hashOfConfig":"9"},{"size":746,"mtime":1607265954632,"results":"11","hashOfConfig":"9"},{"size":287,"mtime":1607081544438,"results":"12","hashOfConfig":"9"},{"size":353,"mtime":1607264649923,"results":"13","hashOfConfig":"9"},{"size":570,"mtime":1607264613644,"results":"14","hashOfConfig":"9"},{"size":1331,"mtime":1607357137121,"results":"15","hashOfConfig":"9"},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"dlgyj4",{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"28","messages":"29","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\reportWebVitals.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\Landing.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\components\\Header.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\index.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\components\\Button.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\App.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\Main.js",[]]
\ No newline at end of file
[{"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\reportWebVitals.js":"1","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\Landing.js":"2","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\components\\Header.js":"3","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\index.js":"4","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\components\\Button.js":"5","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\App.js":"6","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\Main.js":"7","C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\AnalysisPose.js":"8"},{"size":362,"mtime":1606827597211,"results":"9","hashOfConfig":"10"},{"size":0,"mtime":1607082038941,"results":"11","hashOfConfig":"10"},{"size":746,"mtime":1607265954632,"results":"12","hashOfConfig":"10"},{"size":287,"mtime":1607081544438,"results":"13","hashOfConfig":"10"},{"size":353,"mtime":1607264649923,"results":"14","hashOfConfig":"10"},{"size":570,"mtime":1607264613644,"results":"15","hashOfConfig":"10"},{"size":3214,"mtime":1607500306215,"results":"16","hashOfConfig":"10"},{"size":5932,"mtime":1607499647762,"results":"17","hashOfConfig":"10"},{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"dlgyj4",{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"26"},{"filePath":"27","messages":"28","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"31","messages":"32","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\reportWebVitals.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\Landing.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\components\\Header.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\index.js",[],["35","36"],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\components\\Button.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\App.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\Main.js",[],"C:\\Users\\mylit\\Documents\\OSW-HW\\Straight-Up\\straight-up\\src\\AnalysisPose.js",[],{"ruleId":"37","replacedBy":"38"},{"ruleId":"39","replacedBy":"40"},"no-native-reassign",["41"],"no-negated-in-lhs",["42"],"no-global-assign","no-unsafe-negation"]
\ No newline at end of file
...
...
straight-up/package-lock.json
View file @
39b1dab
...
...
@@ -4874,6 +4874,11 @@
"domelementtype"
:
"1"
}
},
"dot"
:
{
"version"
:
"1.1.3"
,
"resolved"
:
"https://registry.npmjs.org/dot/-/dot-1.1.3.tgz"
,
"integrity"
:
"sha512-/nt74Rm+PcfnirXGEdhZleTwGC2LMnuKTeeTIlI82xb5loBBoXNYzr2ezCroPSMtilK8EZIfcNZwOcHN+ib1Lg=="
},
"dot-case"
:
{
"version"
:
"3.0.4"
,
"resolved"
:
"https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz"
,
...
...
@@ -5077,6 +5082,11 @@
"resolved"
:
"https://registry.npmjs.org/entities/-/entities-2.1.0.tgz"
,
"integrity"
:
"sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w=="
},
"env"
:
{
"version"
:
"0.0.2"
,
"resolved"
:
"https://registry.npmjs.org/env/-/env-0.0.2.tgz"
,
"integrity"
:
"sha1-UMGfMHsSmkWEW2tobfWzndQNHPA="
},
"errno"
:
{
"version"
:
"0.1.7"
,
"resolved"
:
"https://registry.npmjs.org/errno/-/errno-0.1.7.tgz"
,
...
...
straight-up/package.json
View file @
39b1dab
...
...
@@ -8,7 +8,9 @@
"@testing-library/user-event"
:
"^12.1.10"
,
"axios"
:
"^0.21.0"
,
"body-parser"
:
"^1.19.0"
,
"dot"
:
"^1.1.3"
,
"dotenv"
:
"^8.2.0"
,
"env"
:
"0.0.2"
,
"express"
:
"^4.17.1"
,
"http-proxy-middleware"
:
"^1.0.6"
,
"moment"
:
"^2.29.1"
,
...
...
straight-up/src/AnalysisPose.js
View file @
39b1dab
...
...
@@ -37,28 +37,28 @@ const checkStraight = (resData, position) => { //resData: API로 받은 JSON 객
if
(
trust_value
[
ear
]
<
0.4
)
{
return
'error_low_trust_value (keypoint:left_ear:4)'
}
if
(
trust_value
[
ear
+
1
]
<
0.4
)
{
if
(
trust_value
[
ear
+
1
]
<
0.4
)
{
return
'error_low_trust_value (keypoint:right_ear:5)'
}
if
(
trust_value
[
shoulder
]
<
0.4
)
{
return
'error_low_trust_value (keypoint:left_shoulder:6)'
}
if
(
trust_value
[
shoulder
+
1
]
<
0.4
)
{
if
(
trust_value
[
shoulder
+
1
]
<
0.4
)
{
return
'error_low_trust_value (keypoint:right_shoulder_7)'
}
//왼쪽귀(4)-왼쪽어깨(6) 거리와 오른쪽귀(5)-오른쪽어깨(7) 거리가 30% 이상 차이날 경우 > 좌우편향
var
d_left
=
distance
(
x_position
[
ear
],
y_position
[
ear
],
x_position
[
shoulder
],
y_position
[
shoulder
]);
var
d_right
=
distance
(
x_position
[
ear
+
1
],
y_position
[
ear
+
1
],
x_position
[
shoulder
+
1
],
y_position
[
shoulder
+
1
]);
var
d_right
=
distance
(
x_position
[
ear
+
1
],
y_position
[
ear
+
1
],
x_position
[
shoulder
+
1
],
y_position
[
shoulder
+
1
]);
var
gap
=
difference
(
d_left
,
d_right
);
if
(
gap
>=
30
)
{
//기운 각도가 3
0도를 넘을 경우
if
(
gap
>=
20
)
{
//기운 각도가 2
0도를 넘을 경우
if
(
d_left
>
d_right
)
{
//오른쪽으로 기울인 경우
return
'leaning right by '
+
gap
+
'percent.'
;
}
else
if
(
d_left
<
d_right
)
{
//왼쪽으로 기울인 경우
return
'leaning left by '
+
gap
+
'percent.'
;
}
}
else
{
//기운 각도가
3
0도 미만인 경우
}
else
{
//기운 각도가
2
0도 미만인 경우
return
'okay'
;
}
...
...
@@ -102,8 +102,3 @@ const checkStraight = (resData, position) => { //resData: API로 받은 JSON 객
}
export
default
checkStraight
;
\ No newline at end of file
/*
console.log(check_straight(response,'front'));
console.log(check_straight(response,'left'));
console.log(check_straight(response,'right'));
*/
\ No newline at end of file
...
...
straight-up/src/Functions.js
deleted
100644 → 0
View file @
f6bbedb
var
response
=
JSON
.
parse
([
`{
"area": 101090.2833,
"bbox": [719.4526, 244.1255, 182.7314, 553.2178],
"category_id": 1,
"keypoints": [
805.4897, 256.4165, 0.8422, 819.5366, 245.0034, 0.8773, 795.8325, 244.1255, 0.8664, 845.8745, 254.6606, 0.8105, 788.8091, 251.1489, 0.5631, 885.3813, 320.5054, 0.7525, 749.3022, 331.9185, 0.7706, 898.5503, 377.5708, 0.7825, 719.4526, 414.4438, 0.7897, 901.1841, 435.5142, 0.7782, 749.3022, 443.4155, 0.8086, 852.02, 504.8706, 0.6854, 785.2974, 511.894, 0.6738, 833.5835, 644.4614, 0.7899, 800.2222, 659.3862, 0.7655, 833.5835, 796.3433, 0.7055, 824.8042, 743.6675, 0.5165
],
"score": 0.7185
}`
]);
console
.
log
(
response
);
//두 좌표 사이의 거리를 반환하는 함수
function
distance
(
x1
,
y1
,
x2
,
y2
){
var
x
=
Math
.
abs
(
x1
-
x2
);
var
y
=
Math
.
abs
(
y1
-
y2
);
var
result
=
Math
.
hypot
(
x
,
y
);
return
result
;
}
//두 길이의 차이를 %비로 반환하는 함수
function
difference
(
d1
,
d2
){
if
(
d1
>
d2
){
return
(
1
-
(
d2
/
d1
))
*
100
;
}
else
if
(
d1
<
d2
){
return
(
1
-
(
d1
/
d2
))
*
100
;
}
else
if
(
d1
==
d2
){
return
0
;
}
}
//객체와 방향정보를 받아 자세정보를 반환하는 함수
function
check_straight
(
jsonObj
,
position
){
//jsonObj: API로 받은 JSON 객체, position: 사진의 방향정보
var
trust_value
=
[];
//17개의 신체부위 좌표에 대한 신뢰도를 저장할 배열
for
(
i
=
2
;
i
<
51
;
i
+=
3
){
trust_value
.
push
(
jsonObj
.
keypoints
[
i
]);
}
var
x_position
=
[];
//17개의 신체부위의 X좌표값을 저장할 배열
for
(
i
=
0
;
i
<
49
;
i
+=
3
){
x_position
.
push
(
jsonObj
.
keypoints
[
i
]);
}
var
y_position
=
[];
//17개의 신체부위의 Y좌표값을 저장할 배열
for
(
i
=
1
;
i
<
50
;
i
+=
3
){
y_position
.
push
(
jsonObj
.
keypoints
[
i
]);
}
if
(
position
==
'front'
){
//정면 사진일 경우
//사용할 데이터의 신뢰도가 0.4 미만이면 실행하지 않음
if
(
trust_value
[
3
]
<
0.4
){
return
'error_low_trust_value (keypoint:4)'
}
if
(
trust_value
[
4
]
<
0.4
){
return
'error_low_trust_value (keypoint:5)'
}
if
(
trust_value
[
5
]
<
0.4
){
return
'error_low_trust_value (keypoint:6)'
}
if
(
trust_value
[
6
]
<
0.4
){
return
'error_low_trust_value (keypoint:7)'
}
//왼쪽귀(4)-왼쪽어깨(6) 거리와 오른쪽귀(5)-오른쪽어깨(7) 거리가 30% 이상 차이날 경우 > 좌우편향
var
d_left
=
distance
(
x_position
[
3
],
y_position
[
3
],
x_position
[
5
],
y_position
[
5
]);
var
d_right
=
distance
(
x_position
[
4
],
y_position
[
4
],
x_position
[
6
],
y_position
[
6
]);
var
gap
=
difference
(
d_left
,
d_right
);
if
(
gap
>=
30
){
//기운 각도가 30도를 넘을 경우
if
(
d_left
>
d_right
){
//오른쪽으로 기울인 경우
return
'leaning right by '
+
gap
+
'percent.'
;
}
else
if
(
d_left
<
d_right
){
//왼쪽으로 기울인 경우
return
'leaning left by '
+
gap
+
'percent.'
;
}
}
else
{
//기운 각도가 30도 미만인 경우
return
'okay'
;
}
}
else
if
(
position
==
'left'
){
//좌측 측면 사진일 경우
//사용할 데이터의 신뢰도가 0.4 미만이면 실행하지 않음
if
(
trust_value
[
11
]
<
0.4
){
return
'error_low_trust_value (keypoint:12)'
}
if
(
trust_value
[
5
]
<
0.4
){
return
'error_low_trust_value (keypoint:6)'
}
if
(
trust_value
[
3
]
<
0.4
){
return
'error_low_trust_value (keypoint:4)'
}
//엉덩이(12)-어깨(6) 각도가 70도 이하일 경우 > 굽은등
var
minimum_angle1
=
(
180
*
70
)
/
Math
.
PI
;
var
d1
=
Math
.
abs
(
x_position
[
11
]
-
x_position
[
5
]);
var
d2
=
Math
.
abs
(
y_position
[
11
]
-
y_position
[
5
]);
var
angle1
=
Math
.
atan
(
d2
/
d1
);
angle1
=
(
180
*
angle1
)
/
Math
.
PI
;
//라디안 > 육십분법 변환
if
(
angle1
<=
minimum_angle1
){
return
'bent_back'
;
}
//어깨(6)-귀(4) 각도가 30도 이상일 경우 > 거북목
var
maximum_angle2
=
(
180
*
30
)
/
Math
.
PI
;
var
d1
=
Math
.
abs
(
y_position
[
3
]
-
y_position
[
5
]);
var
d2
=
Math
.
abs
(
x_position
[
3
]
-
x_position
[
5
]);
var
angle2
=
Math
.
atan
(
d2
/
d1
);
angle2
=
(
180
*
angle2
)
/
Math
.
PI
;
//라디안 > 육십분법 변환
if
(
angle2
>=
maximum_angle2
){
return
'bent_neck'
;
}
//굽은등, 거북목 모두 없을 경우
return
'okay'
;
}
else
if
(
position
==
'right'
){
//우측 측면 사진일 경우
//사용할 데이터의 신뢰도가 0.4 미만이면 실행하지 않음
if
(
trust_value
[
12
]
<
0.4
){
return
'error_low_trust_value (keypoint:13)'
}
if
(
trust_value
[
6
]
<
0.4
){
return
'error_low_trust_value (keypoint:7)'
}
if
(
trust_value
[
4
]
<
0.4
){
return
'error_low_trust_value (keypoint:5)'
}
//엉덩이(13)-어깨(7) 각도가 70도 이하일 경우 > 굽은등
var
minimum_angle1
=
(
180
*
70
)
/
Math
.
PI
;
var
d1
=
Math
.
abs
(
x_position
[
12
]
-
x_position
[
6
]);
var
d2
=
Math
.
abs
(
y_position
[
12
]
-
y_position
[
6
]);
var
angle1
=
Math
.
atan
(
d2
/
d1
);
angle1
=
(
180
*
angle1
)
/
Math
.
PI
;
//라디안 > 육십분법 변환
if
(
angle1
<=
minimum_angle1
){
return
'bent_back'
;
}
//어깨(7)-귀(5) 각도가 30도 이상일 경우 > 거북목
var
maximum_angle2
=
(
180
*
30
)
/
Math
.
PI
;
var
d1
=
Math
.
abs
(
y_position
[
4
]
-
y_position
[
6
]);
var
d2
=
Math
.
abs
(
x_position
[
4
]
-
x_position
[
6
]);
var
angle2
=
Math
.
atan
(
d2
/
d1
);
angle2
=
(
180
*
angle2
)
/
Math
.
PI
;
//라디안 > 육십분법 변환
if
(
angle2
>=
maximum_angle2
){
return
'bent_neck'
;
}
//굽은등, 거북목 모두 없을 경우
return
'okay'
;
}
}
console
.
log
(
check_straight
(
response
,
'front'
));
console
.
log
(
check_straight
(
response
,
'left'
));
console
.
log
(
check_straight
(
response
,
'right'
));
\ No newline at end of file
straight-up/src/Main.js
View file @
39b1dab
...
...
@@ -73,7 +73,7 @@ export default function Main() {
<
/div>
<
div
className
=
"Image_input"
>
<
input
type
=
"file"
name
=
"file"
onChange
=
{
handleChangeFile
}
/>
<
button
type
=
"button"
onClick
=
{
analysisImage
}
/
>
<
button
type
=
"button"
onClick
=
{
analysisImage
}
>
Submit
<
/button
>
<
/div>
<
/div>
)
...
...
Please
register
or
login
to post a comment