Skip to content

IrisPupilTracker is a real-time tool for detecting and analyzing the iris and pupil using OpenCV and MediaPipe. It provides visual overlays and key metrics, enabling applications in eye-tracking and gaze analysis.

Notifications You must be signed in to change notification settings

sanmay-sr/IrisPupilTracker

Repository files navigation

Iris-Pupil Ratio Analyzer

A sophisticated computer vision application for real-time iris-pupil ratio analysis using advanced machine learning algorithms. This professional tool provides precise measurements, generates comprehensive PDF reports, and offers a modern web interface for research and educational applications.

🚀 Key Features

  • Advanced Computer Vision: Utilizes MediaPipe Face Mesh for precise facial landmark detection
  • Real-time Analysis: Live camera capture with instant processing capabilities
  • Professional UI/UX: Modern, responsive interface with gradient styling and smooth animations
  • Comprehensive Reporting: Generates detailed PDF reports with proper image formatting
  • Dual Eye Analysis: Independent analysis of both left and right eyes
  • Research-Grade Accuracy: Implements contour analysis and ellipse fitting for precise measurements

Technical Capabilities

  • Computer Vision Pipeline: Advanced image processing with OpenCV and MediaPipe
  • Machine Learning Integration: Facial landmark detection with 468-point mesh
  • Real-time Processing: Live video stream analysis with instant feedback
  • Professional Reporting: PDF generation with proper aspect ratios and formatting
  • Responsive Design: Cross-platform compatibility with modern web standards
  • Error Handling: Robust validation and user-friendly error messages
  • Data Management: Secure patient information handling and session management

Analysis Capabilities

  • Precision Measurement: Iris and pupil radius calculation in millimeters
  • Advanced Detection: Contour analysis with ellipse fitting for pupil boundaries
  • Ratio Analysis: Iris-to-pupil ratio calculation with clinical reference ranges
  • Visual Annotations: Real-time overlay of detected boundaries on images
  • Clinical Standards: Normal range indicators (2.5-4.0) for research context

Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Local Setup

  1. Clone the repository

    git clone https://github.com/yourusername/iris-pupil-analyzer.git
    cd iris-pupil-analyzer
  2. Install dependencies

    pip install -r requirements.txt
  3. Run the application

    streamlit run app.py
  4. Access the application Open your browser and navigate to http://localhost:8501

Deployment on Streamlit Cloud

Automatic Deployment

  1. Fork this repository to your GitHub account
  2. Connect to Streamlit Cloud:
    • Go to share.streamlit.io
    • Sign in with your GitHub account
    • Click "New app"
    • Select your forked repository
    • Set the main file path to app.py
    • Click "Deploy"

Manual Deployment

  1. Upload files to GitHub:

    • Ensure all files are in your repository
    • Include requirements.txt, setup.sh, and .streamlit/config.toml
  2. Configure Streamlit Cloud:

    • Set the main file path to app.py
    • The setup.sh script will automatically configure the server

Project Structure

iris-pupil-analyzer/
├── app.py                 # Main Streamlit application
├── requirements.txt       # Python dependencies
├── README.md             # Project documentation
├── setup.sh              # Streamlit Cloud deployment script
├── .streamlit/
│   └── config.toml       # Streamlit configuration
└── .gitignore            # Git ignore file

Usage Guide

Step 1: Patient Information

  • Fill in the patient's name, age, gender, and medical conditions in the sidebar
  • Click "Save Patient Info" to store the information

Step 2: Image Input

  • Upload Image: Choose a clear frontal face image (JPG, JPEG, or PNG format)
  • Live Camera Capture: Use your webcam for real-time video capture
    • Click "Start Live Camera" to activate the webcam
    • You'll see a LIVE VIDEO STREAM with a capture button
    • Position your face clearly in the camera view
    • Click the "Take photo" button in the camera widget to capture
    • Use "Reset Camera" to start over if needed
  • Ensure the image has good lighting and visible eyes
  • The image should be high resolution for better accuracy

Step 3: Analysis

  • Click "Analyze Image" to process the uploaded image
  • Wait for the analysis to complete (usually takes 5-10 seconds)
  • Review the results displayed in the right column

Step 4: Report Generation

  • Click "Generate PDF Report" to create a comprehensive report
  • Download the PDF file containing all analysis results and patient information

Technical Architecture

Computer Vision Pipeline

  1. Facial Landmark Detection: MediaPipe Face Mesh with 468-point mesh
  2. Iris Localization: Precise positioning using predefined iris landmarks
  3. Pupil Detection: Advanced contour analysis with ellipse fitting algorithms
  4. Measurement Conversion: Pixel-to-millimeter conversion using IPD reference
  5. Ratio Calculation: Validated iris-to-pupil ratio computation

Core Algorithms

  • MediaPipe Face Mesh: 468 facial landmarks for millimeter-precision detection
  • Contour Analysis: Ellipse fitting with geometric validation for pupil boundaries
  • Adaptive Thresholding: Dynamic image processing for varying lighting conditions
  • Geometric Validation: Physiological range validation for measurement accuracy

Technical Specifications

  • Normal Iris-to-Pupil Ratio: 2.5 - 4.0 (clinical reference range)
  • Average Adult IPD: 63mm (interpupillary distance for pixel-to-mm conversion)
  • Pupil Size Range: 20-70% of iris diameter (physiological validation)
  • Processing Speed: Real-time analysis with <2 second response time

Important Disclaimers

  • Research Use Only: This tool is designed for research and educational purposes
  • Not Medical Advice: Results should not be used for medical diagnosis
  • Professional Consultation: Always consult qualified healthcare professionals
  • Image Quality: Results depend on image quality and lighting conditions

Development Experience

Aytasense Technologies Private Limited (Bangalore Urban, Karnataka)

Aug 2024 - Feb 2025
Machine Learning Intern

  • Developed a real-time IRIS-PUPIL detection pipeline using CNNs, achieving 93% accuracy
  • Engineered a modular architecture with OpenCV and Python, designed for future API-based deployment
  • IRIS-PUPIL Ratio Detection:
    • Created a CNN-based system for real-time pupil measurement using webcam input
    • Designed with modular code and testability, working on simulating REST API integration for scalability in medical applications

Contributing

We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and test thoroughly
  4. Commit your changes: git commit -m 'Add feature'
  5. Push to the branch: git push origin feature-name
  6. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • MediaPipe: For facial landmark detection capabilities
  • OpenCV: For computer vision processing
  • Streamlit: For the web application framework
  • ReportLab: For PDF generation functionality

Support

For support, questions, or feature requests:

  • Open an issue on GitHub
  • Contact the development team
  • Check the documentation for common solutions

Version: 1.0.0
Last Updated: December 2024
Maintainer: Your Name

About

IrisPupilTracker is a real-time tool for detecting and analyzing the iris and pupil using OpenCV and MediaPipe. It provides visual overlays and key metrics, enabling applications in eye-tracking and gaze analysis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published