Spaces:
Sleeping
Sleeping
Update src/detection/strategies/geometric.py
Browse files
src/detection/strategies/geometric.py
CHANGED
@@ -26,6 +26,10 @@ class GeometricProcessor(BaseProcessor):
|
|
26 |
self.MOUTH = [61, 291, 39, 181, 0, 17, 84, 178]
|
27 |
|
28 |
def process_frame(self, frame):
|
|
|
|
|
|
|
|
|
29 |
h, w, _ = frame.shape
|
30 |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
31 |
brightness = np.mean(gray)
|
@@ -46,8 +50,7 @@ class GeometricProcessor(BaseProcessor):
|
|
46 |
score = 0
|
47 |
weights = self.settings['indicator_weights']
|
48 |
|
49 |
-
# --- Draw Facial Landmarks
|
50 |
-
# This will draw the green dots for eyes and mouth.
|
51 |
eye_mouth_landmarks = self.L_EYE + self.R_EYE + self.MOUTH
|
52 |
for idx in eye_mouth_landmarks:
|
53 |
lm = landmarks[idx]
|
@@ -105,4 +108,4 @@ class GeometricProcessor(BaseProcessor):
|
|
105 |
status_text = f"Status: {level} (Score: {score_val:.2f})"
|
106 |
cv2.putText(frame, status_text, (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2, cv2.LINE_AA)
|
107 |
|
108 |
-
return frame, drowsiness_indicators, face_landmarks
|
|
|
26 |
self.MOUTH = [61, 291, 39, 181, 0, 17, 84, 178]
|
27 |
|
28 |
def process_frame(self, frame):
|
29 |
+
# --- CRITICAL FIX ---
|
30 |
+
# Create a writable copy of the frame to prevent read-only errors.
|
31 |
+
frame = frame.copy()
|
32 |
+
|
33 |
h, w, _ = frame.shape
|
34 |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
35 |
brightness = np.mean(gray)
|
|
|
50 |
score = 0
|
51 |
weights = self.settings['indicator_weights']
|
52 |
|
53 |
+
# --- Draw Facial Landmarks ---
|
|
|
54 |
eye_mouth_landmarks = self.L_EYE + self.R_EYE + self.MOUTH
|
55 |
for idx in eye_mouth_landmarks:
|
56 |
lm = landmarks[idx]
|
|
|
108 |
status_text = f"Status: {level} (Score: {score_val:.2f})"
|
109 |
cv2.putText(frame, status_text, (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2, cv2.LINE_AA)
|
110 |
|
111 |
+
return frame, drowsiness_indicators, face_landmarks
|