This application uses computer vision to detect nail-biting behavior and alerts users in real-time. It uses your computer's webcam to monitor hand movements near the mouth and provides immediate feedback when nail-biting is detected.
Version 2.0
- MediaPipe Hand Pose + Geometric Approach (Core Detection):
- Uses MediaPipe's hand landmarks for reliable detection
- Calculates the distance between fingertips and mouth landmarks
- Checks finger orientation relative to the mouth
- Includes gesture recognition for common nail-biting poses
- Added support for Python 3.12
- Updated to latest compatible libraries (TensorFlow 2.18+, MediaPipe 0.10.18+)
Version 1.0
- MediaPipe Hand Pose + Geometric Approach (Quick Solution):
- Instead of relying on the pre-trained classification model, the model uses MediaPipe's hand landmarks
- Calculate the distance between fingertips and mouth landmarks
- Check finger orientation relative to the mouth
- Add gesture recognition for common nail-biting poses
- This would be more reliable and faster than the current ML approach as an MVP
- Real-time webcam monitoring
- Hand and face detection using MediaPipe
- Visual feedback with colored rectangles:
- Blue: Hand detection
- Green: Mouth detection
- Red: Nail-biting detected
- Audio alerts when nail-biting is detected
- Adjustable detection sensitivity
- Event logging for tracking behavior
- Python 3.8-3.12 (Python 3.12 recommended)
- Webcam
- The required Python packages are listed in
requirements.txt
If you're using VS Code with the Dev Containers extension:
- Clone the repository:
git clone <repository-url>
cd nail-biting-detection
- Open the project in VS Code and reopen in container when prompted. The container will automatically set up Python 3.12 and install all dependencies.
- Clone the repository:
git clone <repository-url>
cd nail-biting-detection
- Run the setup script:
./setup_py312.sh
- Activate the virtual environment:
source venv-py312/bin/activate
- Clone the repository:
git clone <repository-url>
cd nail-biting-detection
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
- Install the required packages:
pip install -r requirements.txt
- Generate the alert sound:
cd src/utils
python generate_alert.py
cd ../..
- Start the application:
cd src
python main.py
-
The application window will open with your webcam feed.
-
Click the "Start Monitoring" button to begin detection.
-
Adjust the sensitivity slider if needed:
- Higher values: More sensitive to hand-mouth proximity
- Lower values: Less sensitive
-
The application will:
- Show blue rectangles around detected hands
- Show a green rectangle around your mouth
- Change rectangles to red when nail-biting is detected
- Play an alert sound
- Log the event
-
Click "Stop Monitoring" to pause detection.
The application creates daily log files in the logs
directory. Each log entry includes:
- Timestamp
- Event type
- Additional information (if any)
Feel free to submit issues and enhancement requests!