Accurate Gaze Prediction
Advanced ridge regression and Kalman filtering for smooth, accurate eye tracking using just a webcam
TypeScript-first webcam eye tracking library with React support
npm install @webgazer-ts/core
# or with React
npm install @webgazer-ts/reactpnpm add @webgazer-ts/core
# or with React
pnpm add @webgazer-ts/reactyarn add @webgazer-ts/core
# or with React
yarn add @webgazer-ts/reactimport webgazer from '@webgazer-ts/core';
// Start eye tracking
await webgazer
.setTracker('TFFacemesh')
.setRegression('ridge')
.begin();
// Show video preview
webgazer.showVideoPreview(true);
// Listen to gaze predictions
webgazer.setGazeListener((data, timestamp) => {
console.log(`Gaze at (${data.x}, ${data.y})`);
});import { useWebgazer } from '@webgazer-ts/react';
function App() {
const { gazeData, start, isRunning } = useWebgazer({
autoStart: true,
showVideoPreview: true
});
return (
<div>
<h1>Gaze Tracker</h1>
{gazeData && (
<p>Looking at: ({gazeData.x}, {gazeData.y})</p>
)}
<button onClick={start}>
{isRunning ? 'Running' : 'Start'}
</button>
</div>
);
}Complete API compatibility with Webgazer.js. All your existing code works without changes:
// This is valid Webgazer.js code that works in Webgazer.ts
webgazer.setRegression('ridge')
.setTracker('TFFacemesh')
.setGazeListener((data) => {
console.log(data);
})
.begin();Built with modern tools and best practices:
@webgazer-ts/core - Pure JavaScript/TypeScript implementation
@webgazer-ts/react - React hooks and components
| Metric | Value |
|---|---|
| Prediction Rate | 60 FPS (16.7ms) |
| Accuracy | 100-200px (calibrated) |
| Initialization | ~800ms (model load) |
| Memory Usage | ~50MB (typical) |
| Bundle Size (core) | ~15KB (gzipped) |
| Bundle Size (react) | ~8KB (gzipped) |
Requires WebRTC support and camera permissions.
Webgazer.ts is a TypeScript rewrite of Webgazer.js by the Brown HCI Lab.
Original Authors:
TypeScript Rewrite:
Licensed under GPL-3.0-or-later
For academic research use. See LICENSE for details.