Quick Start Guide
Get your first gaze tracking experiment running in under 10 minutes. This guide walks through setup, configuration, and execution of a basic experiment.
Prerequisites
Required Software
| Tool | Version | Installation |
|---|---|---|
| Node.js | 14.0+ | https://nodejs.org/ |
| http-server | Latest | npm install -g http-server |
| OpenSSL | Any | Included with Git Bash/Linux/macOS |
Hardware Requirements
- Webcam with 720p minimum resolution
- Quad-core CPU (Intel i5/AMD Ryzen 5 or better)
- 8GB RAM minimum (16GB recommended)
- 1920x1080 display minimum
Installation Steps
Step 1: Clone Repository
git clone https://github.com/mrhunsaker/GazeTracking.git
cd GazeTracking
Step 2: Install http-server
npm install -g http-server
sudo npm install -g http-server
SSL Certificate Setup
Modern browsers require HTTPS to access webcams. Generate self-signed SSL certificates:
Generate Certificates
openssl req -nodes -new -x509 -keyout server.key -out server.cert
Certificate Generation Prompts
You can press Enter to skip all prompts, or fill them in as follows:
Country Name: US
State: [Your State]
Locality: [Your City]
Organization: Research Lab
Common Name: localhost
Email: your@email.com
Running Your First Experiment
Step 1: Start the Server
Navigate to the experiment folder and start the HTTPS server:
cd StudentFolders/2025_Students
http-server -S -C server.cert -K server.key -p 8080
You should see:
Starting up http-server, serving ./ through https
Available on:
https://127.0.0.1:8080
https://192.168.1.100:8080
Hit CTRL-C to stop the server
Step 2: Open in Browser
- Open Chrome or Edge (recommended)
- Navigate to
https://localhost:8080 - Click "Advanced" → "Proceed to localhost" (for self-signed cert)
- Allow camera permissions when prompted
Step 3: Initialize Experiment
- Press any key to start initialization
- Enter participant initials (max 6 characters)
- Select test type:
- Shapes: 193 geometric shapes
- Colors: 10 colored objects
- Abstract: 403 abstract patterns
- Select trial count (10-50)
- Click "Start"
Step 4: Calibration
The calibration sequence will begin automatically:
- 9-Point Calibration: Click each yellow dot that appears
- Look directly at each dot before clicking
- Keep your head still
- Maintain consistent posture
- Quality Validation: System automatically tests accuracy
- Refinement (if needed): 3 additional points if quality < 75%
- Sit 50-70cm from screen
- Ensure good lighting on your face
- Remove glasses if possible (reduces reflections)
- Look at the center of each dot, not the edges
Step 5: Run Experiment
After calibration, trials begin automatically:
- Sample Phase: One object shown for 3 seconds
- Delay: 2-second black screen
- Test Phase: Three objects shown for 10 seconds
- Type 1 trials: target + 2 identical foils
- Type 2 trials: target + 2 different foils
- Repeat: Continues for selected trial count
- Periodic Recalibration: 3-point recal every 10 trials
Data Export
When the experiment completes, data is automatically:
- Saved to browser storage (IndexedDB via LocalForage)
- Downloaded as JSON file to your Downloads folder
Data File Format
{
"trialData": [
{
"trialNumber": 1,
"type": 1,
"startTime": 1706284843120,
"endTime": 1706284858125,
"object1": 45,
"testObjects": [45, 127, 127],
"positions": [
{"position": "left", "objectNum": 45, "isTarget": true},
{"position": "center", "objectNum": 127, "isTarget": false},
{"position": "right", "objectNum": 127, "isTarget": false}
],
"gazeData": [/* array of gaze points */]
}
// ... more trials
],
"gazeData": [/* all gaze points across session */],
"timestamp": 1706284860000,
"totalTrials": 20
}
Gaze Data Format
{
"x": 512.3, // Filtered gaze X (pixels)
"y": 384.7, // Filtered gaze Y (pixels)
"rawX": 515.1, // Raw gaze X before filtering
"rawY": 388.2, // Raw gaze Y before filtering
"headPose": {
"roll": 0.05, // Head roll angle (radians)
"pitch": -0.02, // Head pitch angle (radians)
"yaw": 0.08, // Head yaw angle (radians)
"distance": 125.4 // Face distance metric
},
"time": 1706284847123, // Absolute timestamp
"relativeTime": 2543, // Milliseconds since trial start
"phase": "experiment" // 'calibration' or 'experiment'
}
Common Issues & Solutions
Camera Not Detected
Symptom: Browser doesn't prompt for camera permission or WebGazer fails to initialize.
Solutions:
- Check HTTPS: Webcam access requires SSL
# Verify URL starts with https:// https://localhost:8080 ✓ http://localhost:8080 ✗ - Camera Permissions: Check browser settings
- Chrome: Settings → Privacy → Site Settings → Camera
- Edge: Settings → Cookies and site permissions → Camera
- Camera in Use: Close other apps using webcam (Zoom, Skype, etc.)
- Try Different Browser: Chrome recommended, Firefox supported
Poor Calibration Quality
Symptom: Repeated refinement prompts or inaccurate gaze tracking.
Solutions:
- Lighting: Ensure face is well-lit
- Avoid backlighting (window behind you)
- Use front/side lighting
- Avoid harsh shadows on face
- Distance: Sit 50-70cm from screen
- Head Position: Keep head still during calibration
- Glasses: Remove if possible (reflections interfere)
- Camera Angle: Webcam should be at eye level
SSL Certificate Error
Symptom: Browser shows "Your connection is not private" warning.
Solution:
This is expected for self-signed certificates in local development:
- Click "Advanced" button
- Click "Proceed to localhost (unsafe)"
- Allow camera permissions
Slow Performance / Lag
Symptom: Choppy video preview or delayed gaze predictions.
Solutions:
- Close Other Apps: Free up CPU/RAM
- Lower Video Preview Size: Edit in trialManager.js:
webgazer.showVideoPreview(false); // Disable preview - Use Chrome: Best TensorFlow.js performance
- Check System Requirements: Ensure quad-core CPU, 8GB+ RAM
- GPU Acceleration: Enable in browser settings
- Chrome: Settings → System → "Use hardware acceleration when available"
Images Not Loading
Symptom: "Error loading images" or blank trial screens.
Solutions:
- Check Image Folders: Verify folder structure:
StudentFolders/2025_Students/ Shapes/ # 193 images: object001.png to object193.png Colors/ # 10 images: object001.png to object010.png Abstract/ # 403 images: object001.png to object403.png - Case Sensitivity: Folder names must match exactly (Linux/macOS)
- Server Path: Ensure server running from correct directory
- Console Errors: Check browser console (F12) for specific error messages
Next Steps
- Learn about TrialManager class
- Explore all available methods
- Understand gaze tracking pipeline
- Calibration best practices
Example Experiment Workflow
// index.html - include libraries
<script src="webgazer.js"></script>
<script src="localforage.min.js"></script>
<script type="module">
import { initializeExperiment } from './trialManager.js';
document.addEventListener('DOMContentLoaded', () => {
initializeExperiment();
console.log('Press any key to begin');
});
</script>
// Workflow automatically handles:
// 1. Participant dialog
// 2. Image loading
// 3. WebGazer init with enhanced features
// 4. 9-point calibration + validation
// 5. Trial loop with periodic recalibration
// 6. Data export to JSON + LocalForage
Support
If you encounter issues not covered here:
- Check the GitHub Issues
- Review the full API documentation
- Contact: hunsakerconsulting@gmail.com