A real-time face detection application built with Streamlit and OpenCV Haar Cascades, featuring image processing filters and webcam support.
- 📸 Image Upload Mode: Upload and process images with face detection
- 🎥 Real-time Webcam Mode: Live face detection from your camera
- 🎨 Image Processing Filters: Gaussian blur, edge detection, brightness/contrast adjustment
- ⚙️ Adjustable Detection Parameters: Fine-tune scale factor and min neighbors
- 💾 Save Captured Frames: Export processed images with detections
- Python 3.8 or higher
- Webcam (optional, for real-time detection)
-
Clone the repository:
git clone <your-repo-url> cd Face-Detection-App
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
streamlit run app.py
The app will open in your default browser at http://localhost:8501.
docker build -t face-detection-app .
docker run -p 8501:8501 face-detection-app- Click "📷 Image Mode" in the sidebar
- Upload an image (JPG, JPEG, or PNG)
- Adjust detection parameters and filters
- Click "Detect Faces" to see results
- Click "🎥 Webcam Mode" in the sidebar
- Choose processing mode:
- Continuous Detection: Real-time face detection
- Detection on Demand: Detect only when you click
- Filter Only: Apply filters without detection
- Click "Start Webcam"
- Use "📸 Save Current Frame" to export images
Adjust detection sensitivity in the sidebar:
- Scale Factor (1.05-1.5): Lower = more sensitive but slower
- Min Neighbors (1-10): Higher = fewer false positives
- Camera not detected: Check permissions and connections
- Multiple cameras: The app tries indices 0-4 automatically
- Linux: Ensure user is in
videogroup:sudo usermod -a -G video $USER
- Use smaller images for faster processing
- Reduce webcam resolution in
.streamlit/config.toml - Try simpler filters (Gaussian blur vs. edge detection)
If cascade files aren't found, they'll fall back to OpenCV's built-in paths automatically.
pip install pytest pytest-cov
pytest tests/ -v
pytest tests/ --cov=src --cov-report=htmlpip install black mypy
black src/ tests/
mypy src/DIP_Project/
├── app.py # Entry point
├── src/
│ ├── config.py # Configuration and paths
│ ├── detector.py # Face detection logic
│ ├── main.py # Streamlit UI
│ ├── style.py # CSS styling
│ └── utils/
│ └── visualization.py # Drawing utilities
├── haarcascades/ # Haar cascade XML files
├── tests/ # Unit tests
├── .streamlit/ # Streamlit config
├── requirements.txt # Dependencies
└── Dockerfile # Container setup
streamlit: Web UI frameworkopencv-python-headless: Computer vision (no GUI dependencies)numpy: Numerical operationspillow: Image processing
See requirements.txt for pinned versions.
- DNN-based face detection (more accurate)
- MediaPipe face mesh integration
- Video file upload and processing
- Face recognition capabilities
- Export detection metrics (CSV/JSON)
MIT License - see LICENSE file for details.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Submit a pull request
- OpenCV Haar Cascades for face detection
- Streamlit for the interactive UI framework

