Built to order

Gaze Tracking using Webcam and Dlib

A webcam gaze tracker that estimates where on the screen you are looking, built on classical landmarks rather than deep learning. Dlib's 68-point facial landmark model locates both eyes; the pupil center in each eye is estimated from the thresholded pupil blob; and a short 9-point calibration — look at each of nine targets — fits a mapping from pupil positions to screen coordinates. A notebook procedure computes the calibration error on your own run in degrees of visual angle, so the reported accuracy is measured by you, not claimed by us.

Gaze Tracking using Webcam and Dlib - project prototype demo screenshot

The problem

Where someone looks is rich information — for attention studies, hands-free interface experiments, usability testing — but commercial eye trackers are specialized hardware. A laptop webcam plus classical computer vision gets surprisingly far: the geometry of the eye is stable, the pupil is the darkest blob in the eye region, and a short calibration turns pupil positions into screen coordinates. This project builds that pipeline with dlib's 68-point landmark model (Kazemi and Sullivan, 2014), pupil-center estimation by image moments, and a 9-point calibration grid that fits a polynomial mapping per user.

Because every face, webcam and lighting setup differs, accuracy is personal: the included notebook runs a calibration procedure the buyer performs, then computes mean angular error over the calibration points, so the report's numbers come from the buyer's own run. The design target is a few degrees of mean angular error at typical laptop distance in good lighting — and the limitations section is blunt about when it breaks: poor light, glasses glare, head movement after calibration. MPIIGaze (Zhang et al., 2017) is cited as the deep-learning background reference for what appearance-based gaze estimation looks like at research scale.

How it works

  1. The webcam frame is passed to dlib's face detector and the 68-point landmark predictor.
  2. Eye regions are cropped from landmarks 36-47 and converted to grayscale.
  3. The pupil blob is isolated by adaptive thresholding and its center found with image moments.
  4. During calibration, the user looks at nine on-screen targets while pupil positions are recorded.
  5. A polynomial mapping is fit from pupil-center vectors to screen coordinates for that user.
  6. In tracking mode, each frame's pupil centers are mapped through the calibration to a gaze point, drawn live on screen.

Tech stack:

  • Python 3.10, dlib (face detection, 68-point landmarks)
  • OpenCV (frame capture, eye cropping, thresholding)
  • NumPy (pupil geometry and mapping math)
  • scikit-learn (polynomial calibration fit)
  • Jupyter notebook (calibration procedure and error analysis)
  • Matplotlib (calibration grid and residual plots)
  • Tkinter overlay app (calibration targets and live gaze point)
Parameter Value
Landmarks Dlib 68-point model (Kazemi and Sullivan, 2014)
Pupil estimation Adaptive thresholding with image-moment centroid
Calibration 9-point on-screen grid, per-user polynomial mapping
Accuracy Design target of a few degrees mean angular error at laptop distance, measured by the buyer's own calibration run
Output Live gaze-point overlay, session gaze heatmap
Reference MPIIGaze (Zhang et al., 2017) as deep-learning background

Project features

  • Dlib 68-point facial landmark detection for precise eye-region localization
  • Pupil-center estimation from thresholded pupil blobs via image moments
  • 9-point on-screen calibration procedure with per-user mapping fit
  • Real-time gaze-point overlay on the screen during tracking
  • Gaze heatmap logging: dwell points recorded over a session
  • Calibration-quality report with per-point residuals
  • Evaluation notebook computing mean angular error on the buyer's own calibration run
  • Head-pose gating that pauses tracking when the head moves too far

What is included

  • Complete source code (landmarks, pupil estimation, calibration, tracking overlay)
  • Jupyter calibration and evaluation notebook (procedure, angular-error computation, residual plots)
  • Project report PDF (background, eye geometry, calibration method, buyer-run evaluation, limitations)
  • PPT presentation for final review
  • Viva Q&A preparation document (dlib landmarks, pupil detection, calibration math, MPIIGaze context)
  • Setup guide (environment, dlib model download, webcam setup, running calibration)

Limitations & prerequisites

  • Lighting is the dominant failure mode: pupil thresholding degrades in dim or strongly backlit rooms, and the report documents the lighting conditions the evaluation was run under.
  • The calibration is valid only for the head position held during calibration; leaning in, turning or slouching afterward shifts the mapping until recalibration.
  • Glasses glare, heavy eyeliner and drooping eyelids can occlude the pupil blob and break center estimation for those users.
  • This is an educational attention-tracking prototype, not a medical or assistive device — it must not be used for diagnosis, accessibility-critical control or any safety-relevant purpose.

Frequently Asked Questions

How is gaze accuracy measured?

By you: the calibration notebook records your pupil positions on the 9-point grid and computes mean angular error in degrees of visual angle, so the report documents your own run's number rather than a claimed one.

Why dlib instead of a deep gaze network?

The geometric route — landmarks plus pupil blob plus calibration — is transparent, runs on CPU with no training data, and every stage is explainable in a viva. MPIIGaze-style appearance models are cited as the research-scale alternative.

What is MPIIGaze?

The standard in-the-wild gaze dataset and appearance-based baseline from Zhang et al. (2017): hundreds of thousands of face images with gaze labels, used here as background context rather than training data.

Do I need to recalibrate?

Once per seating position. The mapping is fit to your face, webcam and head position; moving the laptop or shifting posture calls for a fresh 30-second calibration.

Does it work with glasses?

Sometimes — it depends on glare and frame occlusion. The limitations section documents this openly, and the calibration residuals will tell you immediately if your setup is unsuitable.

Can it track both eyes?

Yes — pupil centers from both eyes are estimated per frame and averaged into a single gaze vector, which also adds robustness when one eye is briefly occluded. Suitable for B.E./B.Tech final-year projects in Computer Science, AI/ML and Data Science.

Components & software requirements
  • Python 3.10, dlib (face detection, 68-point landmarks)
  • OpenCV (frame capture, eye cropping, thresholding)
  • NumPy (pupil geometry and mapping math)
  • scikit-learn (polynomial calibration fit)
  • Jupyter notebook (calibration procedure and error analysis)
  • Matplotlib (calibration grid and residual plots)
  • Tkinter overlay app (calibration targets and live gaze point)
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download abstract (PDF)

Related guides

All guides
Blueprint-style technical illustration of multiple decision trees voting together into one final predictionStudents with basic Python and pandas skills who want a reliable first classifier for ML coursework and tabular data projects.

Random Forests Explained: Why Decision Trees Vote Better Together

Decision trees are readable but overfit; random forests fix this by training hundreds of varied trees on bootstrapped data with random feature subsets, then letting them vote. This guide explains Gini impurity, bagging, out-of-bag validation and the four hyperparameters that matter, with a complete scikit-learn workflow, honest feature-importance practices, and the mistakes students keep making.

Read guide
Illustration of object tracking showing video frames with bounding boxes and persistent ID labels following people and vehicles, comparing motion prediction and appearance matching.B.E./B.Tech Computer Science and Electronics students building video analytics projects — people counting, vehicle tracking, sports analysis — who have detection working and need

Object Tracking: DeepSORT and ByteTrack Explained

Detection finds objects per frame; tracking keeps their identities across frames. This guide explains tracking-by-detection, Kalman motion models, DeepSORT's appearance embeddings vs ByteTrack's low-confidence box recovery, tracking metrics (HOTA, IDF1, ID switches), and the tuning parameters that determine real-world quality.

Read guide
Illustration of image segmentation showing U-Net's U-shaped encoder-decoder with skip connections producing pixel masks, alongside Mask R-CNN detecting instances with masks.B.E./B.Tech Computer Science and AI/ML students moving from image classification or detection to pixel-level understanding — medical imaging, defect detection, autonomous driving

Image Segmentation: U-Net and Mask R-CNN

When projects need pixel-level answers, segmentation delivers. This guide explains semantic vs instance vs panoptic segmentation, U-Net's encoder-decoder with skip connections, Mask R-CNN's parallel mask head, Dice and IoU evaluation, paired augmentation, and how to choose the right architecture for your data and question.

Read guide
Get a quotation