Spaces:
Runtime error
Runtime error
Update src/detection/strategies/geometric.py
Browse files
src/detection/strategies/geometric.py
CHANGED
|
@@ -26,10 +26,9 @@ class GeometricProcessor(BaseProcessor):
|
|
| 26 |
self.MOUTH = [61, 291, 39, 181, 0, 17, 84, 178]
|
| 27 |
|
| 28 |
def process_frame(self, frame):
|
| 29 |
-
#
|
| 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,9 +49,10 @@ class GeometricProcessor(BaseProcessor):
|
|
| 50 |
score = 0
|
| 51 |
weights = self.settings['indicator_weights']
|
| 52 |
|
| 53 |
-
# --- Draw Facial Landmarks ---
|
| 54 |
-
|
| 55 |
-
|
|
|
|
| 56 |
lm = landmarks[idx]
|
| 57 |
x, y = int(lm.x * w), int(lm.y * h)
|
| 58 |
cv2.circle(frame, (x, y), 1, (0, 255, 0), -1)
|
|
|
|
| 26 |
self.MOUTH = [61, 291, 39, 181, 0, 17, 84, 178]
|
| 27 |
|
| 28 |
def process_frame(self, frame):
|
| 29 |
+
# Create a writable copy to prevent read-only errors from Gradio/OpenCV
|
|
|
|
| 30 |
frame = frame.copy()
|
| 31 |
+
|
| 32 |
h, w, _ = frame.shape
|
| 33 |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
| 34 |
brightness = np.mean(gray)
|
|
|
|
| 49 |
score = 0
|
| 50 |
weights = self.settings['indicator_weights']
|
| 51 |
|
| 52 |
+
# --- Draw Facial Landmarks (Logic Added Back) ---
|
| 53 |
+
# This will draw the green dots for eyes and mouth to show what is being tracked.
|
| 54 |
+
eye_mouth_landmarks_indices = self.L_EYE + self.R_EYE + self.MOUTH
|
| 55 |
+
for idx in eye_mouth_landmarks_indices:
|
| 56 |
lm = landmarks[idx]
|
| 57 |
x, y = int(lm.x * w), int(lm.y * h)
|
| 58 |
cv2.circle(frame, (x, y), 1, (0, 255, 0), -1)
|