Skip to content

Commit

Permalink
Merge pull request #82 from DDD-Community/feat/#46
Browse files Browse the repository at this point in the history
[feat/#46] 거북목 threshold를 인자로 받을 수 있게 수정, 턱 괴기 감도 수정, 꼬리뼈로 앉기 탐지 로직 고도화
  • Loading branch information
lkhoony authored Sep 24, 2024
2 parents 56a5981 + 19a3731 commit 9268d49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/PoseDetector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const PoseDetector: React.FC = () => {
resultRef.current = results
if (snapRef.current) {
const _isShoulderTwist = detectSlope(snapRef.current, results, false)
const _isTextNeck = detectTextNeck(snapRef.current, results, true)
const _isTextNeck = detectTextNeck(snapRef.current, results, true, 0.88)
const _isHandOnChin = detectHandOnChin(snapRef.current, results)
const _isTailboneSit = detectTailboneSit(snapRef.current, results)
const _isShowNoti = userNoti?.duration === "IMMEDIATELY" && userNoti?.isActive
Expand Down
13 changes: 10 additions & 3 deletions src/utils/detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const getXYfromPose = (poses: pose[], name: string): point | null => {
* @param isSnapShotMode 스냅샷 촬영후, 해당 기준으로 자세를 측정할 지 아니면 자동으로 측정할 지
* @returns 거북목 상태라고 판단되면 true, 판단되지 않으면 false, 비교할 수 없는 경우 null을 반환
*/
export const detectTextNeck = (refer: pose[], comp: pose[], isSnapShotMode = true): boolean | null => {
export const detectTextNeck = (refer: pose[], comp: pose[], isSnapShotMode = true, threshold = 1): boolean | null => {
if (!comp) return null

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

const RATIO_DIFF_THRESHOLD = 0.88
const RATIO_DIFF_THRESHOLD = threshold

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

const RATIO_DIFF_THRESHOLD = 0.88

if (referRatio * RATIO_DIFF_THRESHOLD > compRatio && referShoulderMidPointY < compShoulderMidPointY) {
const referAngle = getAngleBetweenLines(referRightShoulderEarSlope, referLeftShoulderEarSlope)
const compAngle = getAngleBetweenLines(compLeftShoulderEarSlope, compRightShoulderEarSlope)

if (
referRatio * RATIO_DIFF_THRESHOLD > compRatio &&
referShoulderMidPointY < compShoulderMidPointY &&
referAngle * 1.2 < compAngle
) {
return true
} else {
return false
Expand Down

0 comments on commit 9268d49

Please sign in to comment.