How astlejoe789/real-time-face-filter-using-opencv works
Purpose and execution model
This is a Python/Jupyter computer-vision demonstration that composites a transparent sunglasses asset onto a still face image. The sole implementation and effective entry point is the interactive notebook: Face Filter.ipynb. It is not currently a webcam or deployable application.
Notebook pipeline
Face Filter.ipynb implements the end-to-end image-processing flow:
1. Load a face image.
2. Load sunglasses as a PNG preserving its alpha channel.
3. Resize the accessory to a manually chosen eye-region size.
4. Split accessory color data from transparency/mask data.
5. Composite the accessory into a face-image region of interest (ROI).
6. Render the augmented result.
Image compositing boundary
The key architectural boundary is between the base face frame and the accessory overlay. The face image supplies the destination ROI; the sunglass PNG supplies color pixels plus alpha-derived masking. Blending/replacement is constrained to the ROI, avoiding modification of unrelated face-image pixels. This logic resides in Face Filter.ipynb.
Positioning and sizing model
Placement is region-based and manually parameterized rather than detection-driven. Sunglasses are resized to fit an expected eye area, then placed at explicit ROI coordinates. Therefore, input images must be compatible with the notebook’s assumed face pose, scale, and location. Automatic face/eye landmark detection is not part of the current repository.
Runtime and dependencies
The runtime is Python in a Jupyter environment. Face Filter.ipynb uses:
• OpenCV for image I/O, resizing, channel/mask manipulation, and compositing.
• NumPy for image-array operations.
• Matplotlib for displaying intermediate or final output.
No dependency manifest, packaged module, server runtime, or external service integration is present in the repository.
Inputs and outputs
Input assets are expected to be a face image and an alpha-enabled sunglass PNG, loaded by the notebook; asset files themselves are not included in the visible tree. The output is an in-memory augmented image displayed from Face Filter.ipynb, rather than a persisted API response, file pipeline, or streaming video frame.
Main entry points: Face Filter.ipynb ROI composite
Components 12
Jupyter Runtime
Interactive Python image-processing workflow.
- Face Filter notebook · Sole implementation and interactive execution surface.
Face Filter.ipynb - OpenCV · Loads, resizes, masks, and composites images.
- NumPy
- Matplotlib
Image Inputs
- Face image · Destination image with an assumed compatible face pose and scale.
- Sunglasses PNG · Supplies accessory color pixels and transparency.
Compositing Pipeline
- Face frame
Face Filter.ipynb - Manual resize · Sizes sunglasses for the expected eye region.
Face Filter.ipynb - Color and alpha split · Separates overlay color data from alpha-derived mask data.
Face Filter.ipynb - Explicit eye ROI · Manually parameterized placement coordinates on the face frame.
Face Filter.ipynb - ROI composite · Applies overlay only within the selected face-image region.
Face Filter.ipynb - Augmented image · Rendered interactively; not persisted or served.
Face Filter.ipynb
Connections 14
- Face Filter notebook → OpenCV: uses
- Face Filter notebook → NumPy: uses
- Face Filter notebook → Matplotlib: uses
- Face image → Face frame: load
- Sunglasses PNG → Manual resize: load
- OpenCV → Face frame: image I/O
- Manual resize → Color and alpha split: resized overlay
- OpenCV → Manual resize: resize
- Color and alpha split → ROI composite: color and mask
- Face frame → Explicit eye ROI: select region
- Explicit eye ROI → ROI composite: destination ROI
- NumPy → ROI composite: array operations
- ROI composite → Augmented image: augmented frame
- Matplotlib → Augmented image: render