@@ -208,7 +208,7 @@ export const detectSlope = (refer: pose[], comp: pose[], isSnapShotMode = true):
208
208
* @param poses 현재 포즈 데이터 배열
209
209
* @returns 손을 턱에 대고 있으면 true, 아니면 false, 판단할 수 없으면 null
210
210
*/
211
- export const detectHandOnChin = ( poses : pose [ ] ) : boolean | null => {
211
+ export const detectHandOnChin = ( refer : pose [ ] , poses : pose [ ] ) : boolean | null => {
212
212
if ( ! poses || poses . length === 0 ) return null
213
213
214
214
// 필요한 키포인트 추출
@@ -223,6 +223,9 @@ export const detectHandOnChin = (poses: pose[]): boolean | null => {
223
223
// 키포인트가 없으면 null 반환
224
224
if ( ! nose || ! leftEar || ! rightEar || ! leftWrist || ! rightWrist || ! leftShoulder || ! rightShoulder ) return null
225
225
226
+ // 손목 모두가 confidence가 없으면 false
227
+ if ( ! leftWrist ?. confidence && ! rightWrist ?. confidence ) return false
228
+
226
229
// 턱의 위치를 추정 (코와 귀 중간점의 중간점)
227
230
const earMidpoint = getMidPoint ( leftEar , rightEar )
228
231
const estimatedChin = getMidPoint ( nose , earMidpoint )
@@ -239,8 +242,21 @@ export const detectHandOnChin = (poses: pose[]): boolean | null => {
239
242
const leftWristToChinDistance = getDistance ( leftWrist , estimatedChin )
240
243
const rightWristToChinDistance = getDistance ( rightWrist , estimatedChin )
241
244
245
+ // 바른자세에서 손만 올린 경우도 턱괴기로 감지 하는 것을 방지
246
+ const isTextNeck = detectTextNeck ( refer , poses , true )
242
247
// 왼손이나 오른손 중 하나라도 턱 근처에 있으면 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
+ ) {
244
260
return true
245
261
}
246
262
0 commit comments