A fun interactive camera application that lets you add overlays to detected faces in real-time.
- Real-time face detection using OpenCV
- Built-in sunglasses overlay
- Custom overlay creation with mouse drawing
- Photo saving with timestamp-based filenames
- Support for multiple faces simultaneously
- Python 3.x
- OpenCV (
opencv-python) - NumPy
- Webcam/Camera device
- Clone this repository:
git clone https://github.com/raffycastlee/capstone/teaching-app.git
cd teaching-app- Create and activate a virtual environment (recommended):
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate- Install required packages:
pip install -r requirements.txtRun the application:
python main.pyBy default, the application uses your system's default camera (usually the built-in webcam on laptops). If you have multiple cameras and want to use a different one, you can modify the camera index in main.py:
# In main.py, change 0 to 1 for second camera, 2 for third camera, etc.
cap = cv2.VideoCapture(0) # 0 is default camera- SPACE: Toggle overlay (switches between no overlay, sunglasses, custom)
- C: Open custom overlay creator
- S: Save current photo
- Q: Quit application
- Press 'C' to open the drawing interface
- Draw your design using the mouse (click and drag)
- Press ENTER to save and use your overlay
- Press ESC to cancel without saving
- All photos are saved in the
photosdirectory - Filenames include timestamps (format:
photo_YYYYMMDD_HHMMSS.jpg) - Photos include any active overlays
If you encounter issues:
- Make sure your camera is connected and not in use by other applications
- Verify OpenCV is installed correctly:
pip install -r requirements.txt - Try closing other applications that might be using the camera
- Ensure you have write permissions in the application directory for saving photos
- Uses Haar cascade classifier for face detection
- Supports real-time overlay scaling based on face size
- Implements non-destructive overlay application
- Custom overlays use white as the transparent color