Skip to content

Commit ef80d36

Browse files
authored
Merge pull request #77 from DDD-Community/feat/#46
[feat/#46] 턱 괴기 자세 탐지 로직 수정, 푸시 알림 타이틀 수정
2 parents 53cdd49 + 3801945 commit ef80d36

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/components/PoseDetector.tsx

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

src/hooks/usePushNotification.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const usePushNotification = (): UsePushNotificationResult => {
4343
// 알림 표시 함수
4444
const showNotification = (body: string): void => {
4545
if (hasPermission) {
46-
new Notification("알림 제목", {
46+
new Notification("자세공작소", {
4747
body: body,
4848
})
4949
}

src/utils/detector.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export const detectSlope = (refer: pose[], comp: pose[], isSnapShotMode = true):
208208
* @param poses 현재 포즈 데이터 배열
209209
* @returns 손을 턱에 대고 있으면 true, 아니면 false, 판단할 수 없으면 null
210210
*/
211-
export const detectHandOnChin = (poses: pose[]): boolean | null => {
211+
export const detectHandOnChin = (refer: pose[], poses: pose[]): boolean | null => {
212212
if (!poses || poses.length === 0) return null
213213

214214
// 필요한 키포인트 추출
@@ -223,6 +223,9 @@ export const detectHandOnChin = (poses: pose[]): boolean | null => {
223223
// 키포인트가 없으면 null 반환
224224
if (!nose || !leftEar || !rightEar || !leftWrist || !rightWrist || !leftShoulder || !rightShoulder) return null
225225

226+
// 손목 모두가 confidence가 없으면 false
227+
if (!leftWrist?.confidence && !rightWrist?.confidence) return false
228+
226229
// 턱의 위치를 추정 (코와 귀 중간점의 중간점)
227230
const earMidpoint = getMidPoint(leftEar, rightEar)
228231
const estimatedChin = getMidPoint(nose, earMidpoint)
@@ -239,8 +242,21 @@ export const detectHandOnChin = (poses: pose[]): boolean | null => {
239242
const leftWristToChinDistance = getDistance(leftWrist, estimatedChin)
240243
const rightWristToChinDistance = getDistance(rightWrist, estimatedChin)
241244

245+
// 바른자세에서 손만 올린 경우도 턱괴기로 감지 하는 것을 방지
246+
const isTextNeck = detectTextNeck(refer, poses, true)
242247
// 왼손이나 오른손 중 하나라도 턱 근처에 있으면 true 반환
243-
if (leftWristToChinDistance < chinProximityThreshold || rightWristToChinDistance < chinProximityThreshold) {
248+
if (
249+
(leftWristToChinDistance < chinProximityThreshold &&
250+
leftWrist?.confidence &&
251+
leftWrist.confidence > 0.2 &&
252+
leftWrist.y > estimatedChin.y &&
253+
isTextNeck) ||
254+
(rightWristToChinDistance < chinProximityThreshold &&
255+
rightWrist?.confidence &&
256+
rightWrist.confidence > 0.2 &&
257+
rightWrist.y > estimatedChin.y &&
258+
isTextNeck)
259+
) {
244260
return true
245261
}
246262

0 commit comments

Comments
 (0)