Skip to content

Commit

Permalink
Merge pull request #95 from DDD-Community/feat/#46
Browse files Browse the repository at this point in the history
[feat/#46] 꼬리뼈 앉기 탐지 로직 수정, 로고 변경, 푸시 알림 아이콘 추가
  • Loading branch information
lkhoony authored Sep 26, 2024
2 parents 9c93bf6 + fba4832 commit fe0bf92
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 52 deletions.
12 changes: 12 additions & 0 deletions src/assets/icons/home-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/assets/icons/side-nav-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Modal/ReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ReportModal = (props: ModalProps): React.ReactElement => {
title,
email,
content: description,
}).then(({ data }) => {
}).then(() => {
if (onSubmit && typeof onSubmit === "function") onSubmit()
})
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/SideNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { clearAccessToken } from "@/api/axiosInstance"
import { useAuthStore } from "@/store/AuthStore"
import { useSnapShotStore } from "@/store/SnapshotStore"
import MainCraftIcon from "@assets/icons/posture-craft-side-nav-icon.svg?react"
import LogoImage from "@assets/icons/side-nav-logo.svg?react"
import AnalysisIcon from "@assets/icons/side-nav-analysis-icon.svg?react"
import CrewIcon from "@assets/icons/side-nav-crew-icon.svg?react"
import MonitoringIcon from "@assets/icons/side-nav-monitor-icon.svg?react"
Expand Down Expand Up @@ -82,8 +82,7 @@ export default function SideNav(): React.ReactElement {
<div>
{/* Logo and Title */}
<div className="flex items-center p-6">
<MainCraftIcon className="h-8 w-8" />
<span className="ml-2 text-xl font-bold">자세공작소</span>
<LogoImage />
</div>

{/* User Info */}
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/usePushNotification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useEffect, useRef } from "react"
import PushIcon from "@assets/icons/favicon.svg"

interface UsePushNotificationResult {
hasPermission: boolean
Expand Down Expand Up @@ -53,6 +54,7 @@ const usePushNotification = (): UsePushNotificationResult => {
if (hasPermissionRef.current) {
new Notification("자세공작소", {
body: body,
icon: PushIcon as string,
})
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MainCraftIcon from "@assets/icons/posture-craft-side-nav-icon.svg?react"
import LogoImage from "@assets/icons/home-logo.svg?react"
import KakaoSignupIcon from "@assets/icons/home-kakao-signup-button-icon.svg?react"
import IntroImage from "@/assets/images/home-intro.png"
import MonitoringImage from "@/assets/images/home-monitoring.png"
Expand All @@ -18,8 +18,7 @@ const HomePage: React.FC = () => {
<div className="flex w-full flex-none border border-[#F0F2F9] px-[120px] py-5">
{/* logo */}
<div className="flex flex-grow items-center">
<MainCraftIcon className="h-8 w-8" />
<span className="ml-2 text-xl font-bold">자세공작소</span>
<LogoImage />
</div>
<button
className="rounded-full bg-blue-600 px-6 py-1 text-sm font-semibold leading-6 text-white"
Expand Down Expand Up @@ -63,10 +62,14 @@ const HomePage: React.FC = () => {
<div className="flex items-center text-[#D9D9D9]">
<div className="mr-20 text-2xl font-bold">ALIGN LAB</div>
<div className="flex gap-20 text-sm">
<a href="https://swjg3gi.notion.site/89966f39e24a442a8eee5b1f91c4fde7" target="_blank">
<a href="https://swjg3gi.notion.site/89966f39e24a442a8eee5b1f91c4fde7" target="_blank" rel="noreferrer">
<div>개인정보처리방침</div>
</a>
<a href="https://swjg3gi.notion.site/7c13aba015654e6f8e1acd300b440526?pvs=4" target="_blank">
<a
href="https://swjg3gi.notion.site/7c13aba015654e6f8e1acd300b440526?pvs=4"
target="_blank"
rel="noreferrer"
>
<div>이용약관</div>
</a>
</div>
Expand Down
50 changes: 7 additions & 43 deletions src/utils/detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,51 +315,15 @@ export const detectTailboneSit = (refer: pose[], comp: pose[]): boolean | null =
// 귀의 중점 계산
const compShoulderMidpoint = getMidPoint(compLeftShoulder, compRightShoulder)

const referForwardHeadDistance = Math.max(referLeftShoulder.y, referRightShoulder.y) - referEarMidpoint.y
const compForwardHeadDistance = Math.max(compLeftShoulder.y, compRightShoulder.y) - compEarMidpoint.y

const referShoulderSlope = getSlopeFromPoints(referLeftShoulder, referRightShoulder)

// 2. 왼쪽 어깨-왼쪽 귀를 잇는 직선의 기울기
const referLeftShoulderEarSlope = getSlopeFromPoints(referLeftShoulder, referLeftEar)

// 3. 오른쪽 어깨-오른쪽 귀를 잇는 직선의 기울기
const referRightShoulderEarSlope = getSlopeFromPoints(referRightShoulder, referRightEar)

const compShoulderSlope = getSlopeFromPoints(compLeftShoulder, compRightShoulder)

// 2. 왼쪽 어깨-왼쪽 귀를 잇는 직선의 기울기
const compLeftShoulderEarSlope = getSlopeFromPoints(compLeftShoulder, compLeftEar)

// 3. 오른쪽 어깨-오른쪽 귀를 잇는 직선의 기울기
const compRightShoulderEarSlope = getSlopeFromPoints(compRightShoulder, compRightEar)

const referLeftAngle = getAngleBetweenLines(referShoulderSlope, referLeftShoulderEarSlope)
const referRightAngle = getAngleBetweenLines(referShoulderSlope, referRightShoulderEarSlope)

const compLeftAngle = getAngleBetweenLines(compShoulderSlope, compLeftShoulderEarSlope)
const compRightAngle = getAngleBetweenLines(compShoulderSlope, compRightShoulderEarSlope)

const referAngleRatio = 1 / (referLeftAngle + referRightAngle)
const compAngleRatio = 1 / (compLeftAngle + compRightAngle)
const referCorrectRatio = (0.4 * referForwardHeadDistance) / (1.5 * referEarDistance + 0.3 * referShoulderDistance)
const compCorrectRatio = (0.4 * compForwardHeadDistance) / (1.5 * compEarDistance + 0.3 * compShoulderDistance)

const referRatio = 0.7 * referCorrectRatio + 0.3 * referAngleRatio
const compRatio = 0.7 * compCorrectRatio + 0.3 * compAngleRatio

const referShoulderMidPointY = referShoulderMidpoint?.y || 1 // 기본값 설정 (1로 설정하여 0으로 나누기 방지)
const compShoulderMidPointY = compShoulderMidpoint?.y || 1 // 기본값 설정

const RATIO_DIFF_THRESHOLD = 0.88

const referAngle = getAngleBetweenLines(referRightShoulderEarSlope, referLeftShoulderEarSlope)
const compAngle = getAngleBetweenLines(compLeftShoulderEarSlope, compRightShoulderEarSlope)
const referRatio = referEarDistance / referShoulderDistance
const compRatio = compEarDistance / compShoulderDistance

if (
referRatio * RATIO_DIFF_THRESHOLD > compRatio &&
referShoulderMidPointY < compShoulderMidPointY &&
referAngle * 1.2 < compAngle
compShoulderDistance / referShoulderDistance < 0.9 &&
compEarDistance / referEarDistance < 0.9 &&
referShoulderMidpoint.y < compShoulderMidpoint.y &&
referEarMidpoint.y < compEarMidpoint.y &&
Math.abs(referRatio - compRatio) > 0.015
) {
return true
} else {
Expand Down

0 comments on commit fe0bf92

Please sign in to comment.