How yashaswinisarangi/real-time-face-detector- works
Project type and purpose
• This is a simple full-stack real-time face-detection web application.
• Purpose: capture video from a local webcam, detect faces using OpenCV and a Haar cascade classifier, and stream the processed video feed to a browser via a Flask server.
File structure
• Top level files:
• app.py – defines the Flask application and HTTP routes for streaming
• main.py – entry point; likely initializes and runs the Flask server
• camera.py – encapsulates webcam access and OpenCV face‐detection logic
• haarcascade_frontalface_default.xml – the pre-trained face-detection model
• README.md – high-level description (no templates or static dirs here)
README for additional insights
• Confirms use of:
• Flask (web framework)
• OpenCV (computer vision)
• Webcam hardware input
• MJPEG or similar streaming technique to browser
a. Main components
1. Web Browser (client)
2. Flask Server (app.py / main.py)
3. Camera Module (camera.py)
4. OpenCV Face-Detection (Haar cascade xml + cv2 library)
5. Webcam Hardware
b. Relationships & interactions
• Client ↔ Flask Server: HTTP GET to “/video_feed” → persistent multipart (MJPEG) response
• Flask Server → Camera Module: on each frame request, call camera.get_frame()
• Camera Module → Webcam: read raw frame from webcam device
• Processed frame flows back up: OpenCV → Camera Module → Flask Server → Client
c. Architectural patterns
• Single-process synchronous model: request triggers capture + processing on the fly
• Streaming API pattern (multipart MJPEG)
• Separation of concerns:
– camera.py handles hardware & CV logic
– app.py handles HTTP and routing
d. Key technologies
• Flask (Python web framework)
• OpenCV (cv2 library) + haarcascade_frontalface_default.xml
• HTML5 / MJPEG streaming in browser
Detailed capture of essential elements
• Continuous loop for real-time streaming.
• Clearly distinguish modules to reflect separation of capture, processing, and serving.