Skip to content

Commit 9268d49

Browse files
authored
Merge pull request #82 from DDD-Community/feat/#46
[feat/#46] 거북목 threshold를 인자로 받을 수 있게 수정, 턱 괴기 감도 수정, 꼬리뼈로 앉기 탐지 로직 고도화
2 parents 56a5981 + 19a3731 commit 9268d49

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/components/PoseDetector.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const PoseDetector: React.FC = () => {
149149
resultRef.current = results
150150
if (snapRef.current) {
151151
const _isShoulderTwist = detectSlope(snapRef.current, results, false)
152-
const _isTextNeck = detectTextNeck(snapRef.current, results, true)
152+
const _isTextNeck = detectTextNeck(snapRef.current, results, true, 0.88)
153153
const _isHandOnChin = detectHandOnChin(snapRef.current, results)
154154
const _isTailboneSit = detectTailboneSit(snapRef.current, results)
155155
const _isShowNoti = userNoti?.duration === "IMMEDIATELY" && userNoti?.isActive

src/utils/detector.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const getXYfromPose = (poses: pose[], name: string): point | null => {
7373
* @param isSnapShotMode 스냅샷 촬영후, 해당 기준으로 자세를 측정할 지 아니면 자동으로 측정할 지
7474
* @returns 거북목 상태라고 판단되면 true, 판단되지 않으면 false, 비교할 수 없는 경우 null을 반환
7575
*/
76-
export const detectTextNeck = (refer: pose[], comp: pose[], isSnapShotMode = true): boolean | null => {
76+
export const detectTextNeck = (refer: pose[], comp: pose[], isSnapShotMode = true, threshold = 1): boolean | null => {
7777
if (!comp) return null
7878

7979
const referLeftEar = getXYfromPose(refer, "left_ear")
@@ -136,7 +136,7 @@ export const detectTextNeck = (refer: pose[], comp: pose[], isSnapShotMode = tru
136136
const referShoulderDistance = getDistance(referLeftShoulder, referRightShoulder)
137137
const compShoulderDistance = getDistance(compLeftShoulder, compRightShoulder)
138138

139-
const RATIO_DIFF_THRESHOLD = 0.88
139+
const RATIO_DIFF_THRESHOLD = threshold
140140

141141
const referRatio =
142142
(0.0001 * referForwardHeadDistance + 1.5 * referShoulderDistance) /
@@ -353,7 +353,14 @@ export const detectTailboneSit = (refer: pose[], comp: pose[]): boolean | null =
353353

354354
const RATIO_DIFF_THRESHOLD = 0.88
355355

356-
if (referRatio * RATIO_DIFF_THRESHOLD > compRatio && referShoulderMidPointY < compShoulderMidPointY) {
356+
const referAngle = getAngleBetweenLines(referRightShoulderEarSlope, referLeftShoulderEarSlope)
357+
const compAngle = getAngleBetweenLines(compLeftShoulderEarSlope, compRightShoulderEarSlope)
358+
359+
if (
360+
referRatio * RATIO_DIFF_THRESHOLD > compRatio &&
361+
referShoulderMidPointY < compShoulderMidPointY &&
362+
referAngle * 1.2 < compAngle
363+
) {
357364
return true
358365
} else {
359366
return false

0 commit comments

Comments
 (0)