Skip to content

bakytbekovJ27/vision-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👁️ Vision Check

Vision Check is a web application designed to help users check their visual acuity and train their eyes. It incorporates AI-powered distance verification for accurate testing.

Vision Check Demo

Features and Functionality

  • Visual Acuity Test: Assesses visual acuity through a letter recognition test.
  • AI-Powered Distance Verification: Uses the device's camera and face detection to ensure the user is at the correct distance from the screen.
  • Eye Training Exercises: Provides exercises to help improve eye muscle strength and reduce eye strain.
  • Result Tracking: Saves and displays test results for monitoring progress.
  • User-Friendly Interface: Simple and intuitive design for ease of use.
  • Admin Panel: Django admin panel for managing test results and training sessions.

Technology Stack

  • Backend:
    • Python 3.x
    • Django 4.2.x
    • PostgreSQL
    • dotenv
  • Frontend:
    • HTML5
    • CSS3
    • JavaScript
    • MediaPipe Face Detection
  • Other:
    • ASGI
    • WSGI

Prerequisites

Before you begin, ensure you have the following installed:

Installation Instructions

  1. Clone the repository:

    git clone https://github.com/bakytbekovJ27/vision-check.git
    cd vision-check
  2. Create a virtual environment:

    python3 -m venv venv
  3. Activate the virtual environment:

    • On macOS and Linux:

      source venv/bin/activate
    • On Windows:

      .\venv\Scripts\activate
  4. Install dependencies:

    pip install -r requirements.txt

    Note: a requirements.txt file was not provided in the repository information, but should be created based on the installed packages. A sample requirements.txt would look like this:

    Django==4.2.7
    psycopg2-binary
    python-dotenv
    
  5. Set up environment variables:

    Create a .env file in the project root directory and add the following variables:

    SECRET_KEY=your_secret_key_here
    DEBUG=True # Set to False in production
    ALLOWED_HOSTS=localhost,127.0.0.1
    
    DB_NAME=eyesight_db
    DB_USER=postgres
    DB_PASSWORD=postgres
    DB_HOST=localhost
    DB_PORT=5432
    
    • Replace your_secret_key_here with a strong, randomly generated secret key.
    • Adjust the database settings according to your PostgreSQL installation.
  6. Apply migrations:

    python manage.py migrate
  7. Create a superuser:

    python manage.py createsuperuser
  8. Collect static files:

    python manage.py collectstatic
  9. Start the development server:

    python manage.py runserver

    Access the application at http://localhost:8000/.

Usage Guide

  1. Home Page: Access the application at http://localhost:8000/ to view the landing page. From here, you can navigate to the Trainer, Test, and Results sections.

  2. Eye Trainer:

    • Navigate to http://localhost:8000/trainer/.
    • Select the movement pattern (Vertical, Horizontal, or Pattern Movement) from the dropdown.
    • Click "Start" to begin the training session.
    • Click "Stop" to pause the session.
    • Click "Reset" to return the moving object to the center.
  3. Vision Test:

    • Navigate to http://localhost:8000/test/.
    • The application will prompt you to verify your distance from the screen using your camera. Follow the on-screen instructions.
    • Enter the letters you see on the screen in the input field.
    • Click "Check" to submit your answer.
    • The test will progress through levels of increasing difficulty.
    • Once the test is complete, you'll be prompted to enter your first and last name to save the results.
  4. Distance Check

    • Navigate to http://localhost:8000/distance-check/
    • The page will automatically access to camera, keep the face in range.
    • Press "Start Check" to begin the distance check session.
  5. Results:

    • Navigate to http://localhost:8000/results/.
    • View your past test results, including the date, score, and level reached. The results are paginated, with 10 results per page.
  6. Admin Panel:

    • Access the admin panel at http://localhost:8000/admin/.
    • Log in with the superuser credentials you created during the installation.
    • Manage TestResult and TrainingSession models. The admin panel provides enhanced displays and filtering for these models as configured in eyesight/admin.py.

API Documentation

The application provides the following API endpoints:

  • POST /api/save-result/: Saves the vision test result.

    • Request Body (JSON):

      {
          "first_name": "string",
          "last_name": "string",
          "score": integer,
          "max_level": integer,
          "distance_check_passed": boolean,
          "average_distance": float,
          "details": {
              "final_font_size": integer
          }
      }
    • Response (JSON):

      {
          "success": true,
          "result_id": integer,
          "message": "Result saved successfully"
      }

      or

      {
        "success": false,
        "error": "string"
      }
  • POST /api/save-training/: Saves a training session.

    • Request Body (JSON):

      {
          "session_type": "vertical" | "horizontal" | "pattern",
          "duration": integer
      }
    • Response (JSON):

      {
          "success": true,
          "session_id": integer,
          "message": "Training session saved"
      }

      or

      {
        "success": false,
        "error": "string"
      }
  • GET /api/statistics/: Retrieves application statistics.

    • Response (JSON):

      {
          "success": true,
          "statistics": {
              "total_tests": integer,
              "total_training_sessions": integer,
              "average_level": float,
              "highest_level": integer,
              "tests_with_distance_check": integer
          }
      }

      or

      {
        "success": false,
        "error": "string"
      }

Contributing Guidelines

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Implement your changes.
  4. Test your changes thoroughly.
  5. Submit a pull request.

Please follow these guidelines:

  • Write clear and concise commit messages.
  • Adhere to PEP 8 style guidelines for Python code.
  • Include relevant tests for new features and bug fixes.
  • Document any API changes.

License Information

The license for this project is not specified. All rights are reserved unless otherwise stated.

About

👁️ Vision Check - Web application for checking visual acuity with AI-powered distance verification

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors