- Introduction
- Architecture
- Project Structure
- Libraries
- Installation
- Usage
- Deployment
- Tests & CI
- License
Smart Focus AI est une application Python qui utilise votre webcam pour détecter en temps réel si vous êtes focalisé·e ou distrait·e, en combinant :
- la direction du regard sans lunettes (gaze) via MediaPipe FaceMesh
- la détection de frappe clavier (TypingActivityDetector)
- le comptage de clignements d’yeux (BlinkDetector)
À la fin de chaque session, elle génère un rapport CSV et un résumé PDF de vos périodes de focus, typing et distraction.
Voici un diagramme Mermaid qui présente les composants principaux et leurs interactions :
flowchart LR
A[Webcam / OpenCV] --> B[FaceMeshDetector]
B --> C[GazeEstimator]
B --> D[BlinkDetector]
E[TypingActivityDetector] --> F[FocusManager]
C --> F
D --> F
F --> G[Streamlit Transformer]
G --> H[Streamlit UI]
F --> I[Logger → CSV / PDF]
- FaceMeshDetector extrait landmarks faciaux
- GazeEstimator et BlinkDetector traitent ces landmarks
- TypingActivityDetector écoute les frappes clavier
- FocusManager fusionne tous les signaux en un état Focused/Distracted
- Streamlit Transformer superpose l’overlay sur la vidéo
- Logger écrit les données et génère le rapport
- .github: GitHub Actions workflows (CI, deploy…).
- logs: logs CSV & PDF reports.
- notebooks/: Exploration & prototypage.
- src/: Source code (gaze, blink, typing, focus).
- tests/: unit & integration tests
- requirements.txt: Dependencies pip.
- setup.py: Packaging setuptools.
- streamlit.py: Streamlit interface.
- mediapipe → FaceMesh & iris tracking.
- numpy → For mathematical operations and numerical array processing.
- matplotlib → For creating classic visualizations (charts, scatter plots, etc.) for PDF reports.
- scikit-learn → Machine-learning models.
- pandas → Log management & data analysis.
- jupyterlab → For developping and testing your analysis interactively in notebooks.
- imutils → OpenCV utilitaires.
- pytestd → For unit tests.
- pynput → Keyboard activity detection.
- fpdf → PDF report creation.
- opencv-python → Captur & video processing.
- pytest → Unit, integration testing & coverage.
- streamlit / streamlit-webrtc (optional) → Real-time web interface.
- pyobjc-framework-AVFoundation (optional) → popup for MacOS camera persmission.
- To clone the repo, run :
git clone https://github.com/GeeksterLab/SmartFocusAI.git
cd smart_focus_ai- Create and activate Python 3.10+ environment, run :
python3.10 -m venv env
source env/bin/activate- Install the idependencies :
pip install -r requirements.txt- Install editable mode : From the root project, instal the package in development mode by running :
pip install -e - Run the main script :
python main.py- Web inteface (Streamlit) :
streamlit run src/streamlit_app.py- You can try this project on Streamlit instead of installing it locally.
- If you also want to try the typing function, you have to install this project locally because
pynputonly works on a local machine, not on a distant server. - Thank you for your understanding. 🙏
Show report, execute : :
pytest --cov=smart_focus_ai --cov-report=term-missing --cov-report=xmlMIT © 2025 [GeeksterLab]