How alok-kumar8765/biometric_face_caputure works
Project Type & Purpose
• This is a full-stack, production-ready Django package (a pluggable app) that provides a client-side face-liveness widget (JavaScript + MediaPipe) and a server-side validation pipeline (Python/Django + OpenCV).
• Purpose: let any Django 4.2+ app drop in a widget to capture a passport-style photo with blink/head-turn liveness checks, then POST a base64 image for brightness/blur/face detection validation.
Main Components
A. Client (Browser)
• MediaPipe FaceMesh SDK (via CDN)
• WidgetHTML + widget.js + widget.css
• JavaScript liveness flow (5-step guide + capture)
B. Django HTTP Layer
• face_liveness_capture.django_integration.urls → routes /face-capture/ and /face-capture/upload/
• widget_view(request) → serves the widget template & CSRF cookie
• upload_face(request) → CSRF-protected POST entry point
C. Backend Pipeline
• detection.verify_liveness(image_base64)
– face_utils.decode_base64_image()
– face_utils.detect_face() (OpenCV Haar Cascade)
– validation.is_bright_enough()
– validation.is_not_blurry()
– face_utils.save_image() → captured_faces/ or Django MEDIA_ROOT
• Returns JSON → {success, path, message, error}
D. Storage
• Local disk (captured_faces/ by default) or configurable Django file storage
E. Demo/Test Project
• A minimal Django project (test_project/) illustrating integration
F. Packaging & Deployment
• Dockerfile + docker-compose.yml + nginx.conf
• GitHub Actions workflows (build, test, publish)
• docs/ for Installation, Deployment, REST API guides
Relationships & Data Flow
1. User loads /face-capture/ → Browser fetches widget HTML/CSS/JS & MediaPipe scripts.
2. Browser requests camera → real-time FaceMesh landmarks → JS guides user through liveness checks.
3. On success → JS encodes photo as data URL → sends POST /face-capture/upload/ + X-CSRFToken.
4. Django upload_face view receives request → calls verify_liveness().
5. Backend pipeline processes image → saves file → returns JSON response.
6. JS parses JSON → displays success/failure to user.
Architectural Patterns & Design Principles
• MVC (Django views + templates) separation
• Clear C/S boundary: client does all heavy ML (MediaPipe), server only lightweight checks
• Pluggable app: isolated django_integration module, static & templates packaged via MANIFEST.in
• REST-style POST endpoint with CSRF protection
• Modular Python backend: detection, utils, validation layers
Technologies & Frameworks
• Frontend: HTML5, CSS, vanilla JavaScript, MediaPipe FaceMesh (CDN)
• Backend: Python 3.8+, Django ≥4.2, OpenCV (opencv-python), NumPy
• Packaging: setuptools/pyproject.toml, pip-editable installs
• CI/CD: GitHub Actions, Docker, docker-compose, optional Nginx reverse proxy