Spaces:
Running
Running
File size: 1,178 Bytes
e735bf3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
from dataclasses import dataclass, field
from typing import Optional, Tuple, List
@dataclass
class FeedbackMessage:
category: str
message: str
severity: str # "warning", "error", "success"
@dataclass
class QualityFeedback:
messages: List[FeedbackMessage] = field(default_factory=list)
is_acceptable: bool = True
def add(self, category: str, message: str, severity: str = "warning"):
self.messages.append(FeedbackMessage(category, message, severity))
if severity == "error":
self.is_acceptable = False
@dataclass
class FingerQualityResult:
# Raw scores
blur_score: float
illumination_score: float
coverage_ratio: float
orientation_angle_deg: float # angle of main axis w.r.t. x-axis
# Per-metric pass/fail
blur_pass: bool
illumination_pass: bool
coverage_pass: bool
orientation_pass: bool
# Overall
quality_score: float # 0–1
overall_pass: bool
# Debug / geometry
bbox: Optional[Tuple[int, int, int, int]] # x, y, w, h
contour_area: float
# NEW: Feedback bundled into the same result JSON
feedback: Optional[QualityFeedback] = None
|