-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmask_detection.py
More file actions
32 lines (26 loc) · 990 Bytes
/
mask_detection.py
File metadata and controls
32 lines (26 loc) · 990 Bytes
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
# mask_detection.py
from utils import bbox_overlap, extract_boxes
def process_face_mask(mask_results, hand_boxes, model_names, hand_on_mouth_threshold):
"""
Processes mask detections and checks for hand-on-mouth overlap.
"""
final_face_detections = []
mask_detections = extract_boxes(mask_results)
for mask_det in mask_detections:
face_box = mask_det['box']
label = model_names.get(mask_det['class'], 'unknown')
confidence = mask_det['confidence']
# check hand overlap
is_hand_on_mouth = False
for hand_box in hand_boxes:
if bbox_overlap(face_box, hand_box) > hand_on_mouth_threshold:
is_hand_on_mouth = True
break
if is_hand_on_mouth:
label = "Hand on Mouth"
final_face_detections.append({
'box': face_box,
'label': label,
'confidence': confidence
})
return final_face_detections