📐 Distance → Diopter Calculator

Enter your current screen-to-eye distance to estimate the myopia correction level using the standard optometric formula.

Diopter Value
-3.33 D
Severity
Moderate
D = −100 ÷ distance (cm)

📊 Myopia Severity Scale

0–3 D
Mild
3–6 D
Moderate
6–9 D
High
> 9 D
Severe

⚠️ Educational estimates only. Always consult a licensed optometrist for professional assessment and prescription.

💡 Healthy Viewing Distance Guide

Device Min (cm) Ideal (cm) D @ Ideal
📱 Smartphone 30 40 −2.50 D
💻 Laptop 45 60 −1.67 D
🖥 Desktop Monitor 60 70 −1.43 D
📺 TV 200 300 −0.33 D

📷 Live Distance Measurement

Opens your front camera, detects your iris positions in real-time, and calculates how far you are from the screen every frame.

--
Distance cm
--
Diopters
--
IPD pixels
Waiting for camera… 0 / 20 frames

ℹ How It Works

1. Face detection — MediaPipe Face Mesh maps 478 landmark points on your face per frame.
2. Iris centres — Landmarks #468 (left iris) and #473 (right iris) give the IPD in pixels.
3. Distance formula — Known average IPD (63 mm) + camera focal length → distance via similar triangles.
4. Smoothing — The last 20 frames are averaged to remove blink and motion noise.

📈 Myopia Prevalence by Age & Region

Percentage of population with myopia across age groups (6–20 yrs).

📱 Screen Time Risk Correlation

Daily screen hours vs estimated myopia development risk (%). Colour: green = low, red = high.

🌍 Global Myopia Projection

Global cases in millions. Orange points = projections. Source: Brien Holden Vision Institute 2016.

🔬 Core Formula

The diopter (D) is the unit of optical power — it equals 1 metre divided by the focal length. For the near point formula:

D = −100 ÷ distance (cm)

At 30 cm → D = −3.33 (moderate myopia range)
At 50 cm → D = −2.00 (mild myopia range)
The negative sign indicates a diverging (concave) lens — used to correct nearsightedness.

👁 IPD-Based Distance Estimation

IPD (inter-pupillary distance) is the gap between your two pupil centres — on average 63 mm in adults. Because we know this real-world length, we can use it as a ruler in the camera image:

distance_mm = (63 mm × focal_px) ÷ IPD_pixels

focal_px ≈ 650 px — estimated focal length of a typical phone front camera.
IPD_pixels = pixel gap between landmarks #468 and #473 in each video frame.

📏 Credit Card Calibration

Every screen has a different pixel density (PPI). The ISO 7810 standard defines a credit card as exactly 85.6 mm wide. Matching an on-screen rectangle to your card gives:

pixels_per_mm = slider_px ÷ 85.6

Saved to localStorage on your device — never uploaded anywhere.

⚠️ Limitations & Disclaimer

• For educational awareness only — not a clinical diagnostic tool.
• Assumes average adult IPD (63 mm). Children and individuals with unusual IPD will see less accurate readings.
• Accuracy ±15–25% typical. Bright backlighting improves landmark detection.
Always consult a registered optometrist for actual eye examination and prescription.

🧠 About OcularAI

OcularAI is an open-source smartphone myopia awareness tool built as a final-year BTech project. Originally a Streamlit Python app, v2.0 is a fully static web app deployed on Vercel — no backend, no sleep delays, and real camera access on any device.

⚙️ Tech Stack

MediaPipe
Face Mesh JS
Chart.js
Research Charts
Vercel
Free Hosting
Vanilla JS
No Framework

🔗 Links

📁 GitHub: github.com/thesouravburman/ocular-ai
👨‍💻 Author: @thesouravburman
📄 License: MIT