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.
- 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.
- Backend:
- Python 3.x
- Django 4.2.x
- PostgreSQL
- dotenv
- Frontend:
- HTML5
- CSS3
- JavaScript
- MediaPipe Face Detection
- Other:
- ASGI
- WSGI
Before you begin, ensure you have the following installed:
- Python 3.x (https://www.python.org/)
- pip (Python package installer)
- PostgreSQL (https://www.postgresql.org/)
-
Clone the repository:
git clone https://github.com/bakytbekovJ27/vision-check.git cd vision-check -
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
-
On macOS and Linux:
source venv/bin/activate -
On Windows:
.\venv\Scripts\activate
-
-
Install dependencies:
pip install -r requirements.txt
Note: a
requirements.txtfile was not provided in the repository information, but should be created based on the installed packages. A samplerequirements.txtwould look like this:Django==4.2.7 psycopg2-binary python-dotenv -
Set up environment variables:
Create a
.envfile 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_herewith a strong, randomly generated secret key. - Adjust the database settings according to your PostgreSQL installation.
- Replace
-
Apply migrations:
python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Collect static files:
python manage.py collectstatic
-
Start the development server:
python manage.py runserver
Access the application at
http://localhost:8000/.
-
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. -
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.
- Navigate to
-
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.
- Navigate to
-
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.
- Navigate to
-
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.
- Navigate to
-
Admin Panel:
- Access the admin panel at
http://localhost:8000/admin/. - Log in with the superuser credentials you created during the installation.
- Manage
TestResultandTrainingSessionmodels. The admin panel provides enhanced displays and filtering for these models as configured ineyesight/admin.py.
- Access the admin panel at
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" }
-
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Implement your changes.
- Test your changes thoroughly.
- 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.
The license for this project is not specified. All rights are reserved unless otherwise stated.
