2026-02-25 15:05:58 +09:00
|
|
|
from pydantic.main import BaseModel
|
|
|
|
|
from enum import Enum
|
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
from typing import List, Optional
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
#=========================================
|
|
|
|
|
class Header(BaseModel):
|
|
|
|
|
camera_id: str
|
2026-03-04 16:54:28 +09:00
|
|
|
ward_id: str | None
|
|
|
|
|
timestamp: str
|
2026-02-25 15:05:58 +09:00
|
|
|
frame_id: int
|
|
|
|
|
#=========================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=========================================
|
|
|
|
|
class SyestemHealth(str,Enum):
|
|
|
|
|
ok = "OK"
|
|
|
|
|
overload = "OVERLOAD"
|
|
|
|
|
critical = "CRITICAL"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Summary(BaseModel):
|
|
|
|
|
active_alerts_count: int
|
|
|
|
|
total_objects_count: int
|
|
|
|
|
system_health: SyestemHealth
|
|
|
|
|
#=========================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=========================================
|
|
|
|
|
class Status(str,Enum):
|
|
|
|
|
stable = "STABLE"
|
|
|
|
|
fall_detected = "FALL_DETECTED"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StatusDetail(str,Enum):
|
|
|
|
|
sudden_fall = "SUDDEN_FALL"
|
|
|
|
|
slip_down = "SLIP_DOWN"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Severity(str,Enum):
|
|
|
|
|
low = "LOW"
|
|
|
|
|
medium = "MEDIUM"
|
|
|
|
|
critical = "CRITICAL"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Metrics(BaseModel):
|
|
|
|
|
velocity: float
|
|
|
|
|
angle: float
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ObjectVisualData(BaseModel):
|
|
|
|
|
format: str
|
|
|
|
|
has_image: bool
|
|
|
|
|
base64_str: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DetectedObject(BaseModel):
|
|
|
|
|
tracking_id: int|None
|
|
|
|
|
status: Status
|
|
|
|
|
status_detail: StatusDetail|None
|
|
|
|
|
severity: Severity|None
|
|
|
|
|
location_zone: str
|
|
|
|
|
duration: float
|
|
|
|
|
bbox: List[int] # [x1, y1, x2, y2]
|
|
|
|
|
skeleton: Optional[List[List[float]]]
|
|
|
|
|
metrics: Metrics
|
|
|
|
|
visual_data: ObjectVisualData
|
|
|
|
|
#=========================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=========================================
|
|
|
|
|
class VisualData(BaseModel):
|
|
|
|
|
format: str
|
|
|
|
|
has_image: bool
|
|
|
|
|
base64_str: str
|
|
|
|
|
#=========================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=========================================
|
|
|
|
|
class FallDetectionSchema(BaseModel):
|
|
|
|
|
header: Header
|
|
|
|
|
summary: Summary
|
|
|
|
|
objects: List[DetectedObject]
|
|
|
|
|
visual_data: VisualData
|
|
|
|
|
#=========================================
|