Skip to content

Hyang0219/Nail-Biting-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nail-Biting Detection Application

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

Features

  • 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

Requirements

  • Python 3.8-3.12 (Python 3.12 recommended)
  • Webcam
  • The required Python packages are listed in requirements.txt

Installation

Option 1: Using Dev Container (Recommended)

If you're using VS Code with the Dev Containers extension:

  1. Clone the repository:
git clone <repository-url>
cd nail-biting-detection
  1. 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.

Option 2: Manual Setup with Python 3.12

  1. Clone the repository:
git clone <repository-url>
cd nail-biting-detection
  1. Run the setup script:
./setup_py312.sh
  1. Activate the virtual environment:
source venv-py312/bin/activate

Option 3: Traditional Setup (Python 3.8-3.10)

  1. Clone the repository:
git clone <repository-url>
cd nail-biting-detection
  1. Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate  # On Windows, use: venv\Scripts\activate
  1. Install the required packages:
pip install -r requirements.txt
  1. Generate the alert sound:
cd src/utils
python generate_alert.py
cd ../..

Usage

  1. Start the application:
cd src
python main.py
  1. The application window will open with your webcam feed.

  2. Click the "Start Monitoring" button to begin detection.

  3. Adjust the sensitivity slider if needed:

    • Higher values: More sensitive to hand-mouth proximity
    • Lower values: Less sensitive
  4. 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
  5. Click "Stop Monitoring" to pause detection.

Logs

The application creates daily log files in the logs directory. Each log entry includes:

  • Timestamp
  • Event type
  • Additional information (if any)

Contributing

Feel free to submit issues and enhancement requests!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published