ThisCalculator

Technology

Eye Aspect Ratio Formula & How to Compute It

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Eye Aspect Ratio Formula & How to Compute It

This calculator computes the eye aspect ratio (EAR) from the 2D coordinates of six facial landmarks around one eye. You enter the (x, y) positions of the left and right eye corners and the two upper and two lower eyelid points, and the result is a dimensionless number that indicates how open the eye is. The formula is widely used in drowsiness-detection and blink-detection systems because it is simple, fast, and works with any face-landmark detector that outputs those six points.

Formula

The standard eye aspect ratio (EAR) is:

EAR = (||P1 − P2|| + ||P3 − P4||) / (2 × ||P5 − P6||)

Where:

  • P1 and P2 are the two vertical distances between the upper and lower eyelid at two horizontal positions (typically the inner and outer edges of the iris).
  • P3 and P4 are the same vertical distances at the other two positions (often the left and right corners of the eye).
  • P5 and P6 are the horizontal distance between the left and right eye corners.
  • ||·|| denotes the Euclidean distance between two points: sqrt((x2−x1)² + (y2−y1)²).

All coordinates are in pixels (or any consistent unit). The result is a dimensionless ratio. For a typical open eye, EAR is roughly 0.25 to 0.35; for a closed eye, it drops to near 0.05 or less.

Worked Example

Using the default values from the calculator:

  • P1 = (100, 100), P2 = (200, 100)
  • P3 = (150, 80), P4 = (150, 120)
  • P5 = (50, 100), P6 = (250, 100)

Compute the distances:

  • ||P1−P2|| = sqrt((200−100)² + (100−100)²) = sqrt(100² + 0) = 100
  • ||P3−P4|| = sqrt((150−150)² + (120−80)²) = sqrt(0 + 40²) = 40
  • ||P5−P6|| = sqrt((250−50)² + (100−100)²) = sqrt(200² + 0) = 200

Then EAR = (100 + 40) / (2 × 200) = 140 / 400 = 0.35. The calculator displays 0.350.

Why the Eye Aspect Ratio Is Useful

The EAR was introduced in 2016 by Soukupová and Čech in a paper titled “Real-Time Eye Blink Detection using Facial Landmarks.� It exploits the fact that the vertical distances between eyelids change dramatically when blinking, while the horizontal distance between eye corners remains relatively stable. Because it is a ratio, it is largely invariant to face scale, distance from camera, and image resolution—as long as the landmarks are detected consistently.

Common applications include:

  • Driver drowsiness detection: a low EAR over several consecutive frames indicates closed eyes.
  • Blink detection for human-computer interaction (e.g., hands-free commands).
  • Medical monitoring of eyelid droop (ptosis) or fatigue.
  • Animation and facial expression analysis.

How to Choose the Six Landmark Points

Most face-landmark models (e.g., Dlib’s 68-point model, MediaPipe’s 468-point model) provide indices for the eye region. For Dlib, the six points for the right eye are indices 36–41, and for the left eye 42–47. The mapping is:

  • P1 and P2: upper eyelid points (e.g., indices 37 and 38 for right eye).
  • P3 and P4: lower eyelid points (e.g., indices 40 and 41).
  • P5 and P6: eye corners (e.g., indices 36 and 39).

If you are using a different detector, check its documentation for the corresponding indices. The key is that P5 and P6 must be the two farthest horizontal points (the corners), and P1–P4 should be the upper and lower lid points at roughly the same horizontal positions as the corners.

Common Mistakes and Pitfalls

  • Using the wrong points: Swapping a corner with a lid point will produce a meaningless ratio.
  • Mixing units: If some coordinates are in pixels and others in millimeters, the ratio is wrong. Always use the same unit.
  • Ignoring head pose: When the head tilts or rotates, the distances change, and the EAR may vary even if the eye is equally open. Some systems compensate by using both eyes or by tracking head pose.
  • Threshold selection: A fixed EAR threshold (e.g., 0.2) may not work for all faces. Calibration per user is recommended.

Limitations of the Formula

The EAR is a heuristic, not a perfect measure of eyelid opening. It assumes the eye is roughly horizontal and the landmarks are accurate. It fails when:

  • The face is heavily occluded (e.g., glasses, hair).
  • The eye is squinting (the ratio may be low even when the eye is open).
  • The camera is at an extreme angle (perspective distortion).
  • The landmark detector gives jittery points (then smoothing is needed).

For robust drowsiness detection, the EAR is often combined with the percentage of time the eyes are closed (PERCLOS) or with head-pose estimation.

Frequently Asked Questions

What is a normal EAR value?

For a fully open eye, EAR typically ranges from 0.25 to 0.35, but it varies with face shape and camera angle. A closed eye gives an EAR near 0.05 or lower. It is best to calibrate per person.

Can I use EAR for both eyes at once?

Yes, you can compute the EAR for each eye separately and then take the average. Averaging reduces noise and is common in drowsiness monitors. However, if one eye is closed and the other open, the average will be moderate, so you may also want to check each eye individually.

Does image resolution affect the EAR?

In theory, no, because the ratio cancels out scale. In practice, lower resolution makes landmark detection less accurate, so the computed EAR may be noisier. Use the highest resolution that your detector can handle in real time.

How do I set a threshold for blink detection?

Record a few seconds of the person with eyes open and closed, compute the EAR for both states, and set the threshold midway between the two averages. For example, if open is 0.30 and closed is 0.05, a threshold of 0.15 works. Some systems use two thresholds: one for closing and one for opening (hysteresis) to avoid flicker.

Is the EAR patented or proprietary?

No, the formula is published in an academic paper and is freely usable. Many open-source projects implement it (e.g., Dlib examples). No license is needed for research or commercial use, though the original paper should be cited if you publish.

What if my landmarks are not in the same order?

You must map your detector’s output to the six points correctly. For example, MediaPipe’s face mesh provides 468 points; the eye region indices are different from Dlib’s. Check the documentation or visualize the points to confirm which indices correspond to the corners and lids.

Related

Formula used
in p1x | Point 1 x | px | 100 | 0
in p1y | Point 1 y | px | 100 | 0
in p2x | Point 2 x | px | 200 | 0
in p2y | Point 2 y | px | 100 | 0
in p3x | Point 3 x | px | 150 | 0
in p3y | Point 3 y | px | 80 | 0
in p4x | Point 4 x | px | 150 | 0
in p4y | Point 4 y | px | 120 | 0
in p5x | Point 5 x | px | 50 | 0
in p5y | Point 5 y | px | 100 | 0
in p6x | Point 6 x | px | 250 | 0
in p6y | Point 6 y | px | 100 | 0
out ear | Eye aspect ratio | - | (dist(p1,p2)+dist(p3,p4))/(2*dist(p5,p6)) | 3
out d1 | Distance p1-p2 | px | dist(p1,p2) | 2
out d2 | Distance p3-p4 | px | dist(p3,p4) | 2
out d3 | Distance p5-p6 | px | dist(p5,p6) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.