feat: migrate from face detection to HOG person detection

This commit is contained in:
2026-01-21 11:39:32 +01:00
parent cae56c40cc
commit b68fa2614e
7 changed files with 158 additions and 1987 deletions

View File

@@ -6,7 +6,7 @@ Integrates face detection and zone tracking.
import cv2
import threading
import time
from face_detector import FaceDetector
from person_detector import PersonDetector
from zone_tracker import ZoneTracker
@@ -18,8 +18,8 @@ class Camera:
Args:
camera_index: Index of the USB camera (usually 0)
process_every_n_frames: Process face detection every N frames for performance
face_confidence: Confidence threshold for face detection
process_every_n_frames: Process detection every N frames for performance
face_confidence: Confidence threshold for person detection
frame_width: Desired frame width
frame_height: Desired frame height
"""
@@ -37,8 +37,8 @@ class Camera:
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, frame_width)
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height)
# Initialize face detector and zone tracker
self.face_detector = FaceDetector(confidence_threshold=face_confidence)
# Initialize person detector and zone tracker
self.person_detector = PersonDetector(confidence_threshold=face_confidence)
self.zone_tracker = None # Will be initialized after first frame
# Frame processing state
@@ -95,7 +95,7 @@ class Camera:
with self.lock:
self.current_frame = frame.copy()
# Process face detection every N frames
# Process detection every N frames
if self.frame_counter % self.process_every_n_frames == 0:
processed_frame, counts = self._process_frame(frame)
with self.lock:
@@ -104,7 +104,7 @@ class Camera:
def _process_frame(self, frame):
"""
Process a single frame: detect faces, track zones, update counts.
Process a single frame: detect people, track zones, update counts.
Args:
frame: Input frame from camera
@@ -112,12 +112,12 @@ class Camera:
Returns:
Tuple of (processed_frame, counts_dict)
"""
# Detect faces
faces = self.face_detector.detect_faces(frame)
# Detect people
people = self.person_detector.detect_people(frame)
# Track zones and update counts
if self.zone_tracker:
counts = self.zone_tracker.process_faces(faces)
counts = self.zone_tracker.process_faces(people)
else:
counts = {
'total_entered': 0,
@@ -131,8 +131,8 @@ class Camera:
else:
processed_frame = frame.copy()
# Draw faces on frame
processed_frame = self.face_detector.draw_faces(processed_frame, faces)
# Draw people on frame
processed_frame = self.person_detector.draw_people(processed_frame, people)
# Draw count information on frame
text_y = 60