Skip to content

Commit

Permalink
feat: 카메라 rate 수정, 어깨 기울기 민감도 조정
Browse files Browse the repository at this point in the history
  • Loading branch information
lkhoony committed Aug 3, 2024
1 parent 9bc36ed commit 2f2f810
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/Camera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Camera: React.FC<WebcamProps> = ({ onStreamReady }) => {
video: {
facingMode: "user",
frameRate: {
ideal: 5,
ideal: 60,
},
},
})
Expand Down
30 changes: 21 additions & 9 deletions src/utils/detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ export const detectSlope = (refer: pose[], comp: pose[], isSnapShotMode: boolean
const compLeftShoulder = getXYfromPose(comp, "left_shoulder")
const compRightShoulder = getXYfromPose(comp, "right_shoulder")

const SHOULDER_DIFF_THRESHOLD = 60

if (!isSnapShotMode && compLeftShoulder && compRightShoulder) {
const SHOULDER_DIFF_THRESHOLD = 40

const shoulderSlope = compLeftShoulder.y - compRightShoulder.y

if (Math.abs(shoulderSlope) < SHOULDER_DIFF_THRESHOLD) {
Expand All @@ -172,14 +174,24 @@ export const detectSlope = (refer: pose[], comp: pose[], isSnapShotMode: boolean
if (referSlope === Infinity || compSlope === Infinity) return null

// referSlope를 기준으로 10% 오차 미만이면, 정상 자세인 것으로 간주
const tenPercentOfReferSlope = Math.abs(referSlope) * 0.9
const slopeDifference = Math.abs(referSlope - compSlope)

if (slopeDifference <= tenPercentOfReferSlope) {
return "올바른 자세입니다"
} else if (referSlope < compSlope) {
return "왼쪽으로 치우쳐져 있습니다"
// const tenPercentOfReferSlope = Math.abs(referSlope) * 0.9
// const slopeDifference = Math.abs(referSlope - compSlope)

// if (shoulderSlope) {
// return "올바른 자세입니다"
// } else if (referSlope < compSlope) {
// return "왼쪽으로 치우쳐져 있습니다"
// } else {
// return "오른쪽으로 치우쳐져 있습니다"
// }

const shoulderSlope = compLeftShoulder.y - compRightShoulder.y

if (Math.abs(shoulderSlope) < SHOULDER_DIFF_THRESHOLD) {
return "적절한 자세입니다"
} else if (shoulderSlope > 0) {
return "오른쪽 어깨가 올라갔습니다"
} else {
return "오른쪽으로 치우쳐져 있습니다"
return "왼쪽 어깨가 올라갔습니다"
}
}

0 comments on commit 2f2f810

Please sign in to comment.