Smartphone-based myopia screening powered by computer vision & face mesh analysis
Enter your current screen-to-eye distance to estimate the myopia correction level using the standard optometric formula.
⚠️ Educational estimates only. Always consult a licensed optometrist for professional assessment and prescription.
| 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 |
Opens your front camera, detects your iris positions in real-time, and calculates how far you are from the screen every frame.
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.
Percentage of population with myopia across age groups (6–20 yrs).
Daily screen hours vs estimated myopia development risk (%). Colour: green = low, red = high.
Global cases in millions. Orange points = projections. Source: Brien Holden Vision Institute 2016.
The diopter (D) is the unit of optical power — it equals 1 metre divided by the focal length. For the near point formula:
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 (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:
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.
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:
Saved to localStorage on your device — never uploaded anywhere.
• 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.
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.
📁 GitHub:
github.com/thesouravburman/ocular-ai
👨💻 Author:
@thesouravburman
📄 License: MIT