An AI-powered web application to track user screen time by analyzing eye gaze with a webcam, built with Go and face-api.js.
This demo shows the real-time eye tracking and focus detection in action.
- Real-time Eye Tracking: Uses
face-api.jsto detect facial landmarks and determine if the user is looking at the screen. - Accurate Time Logging: A Go backend logs the total time the user is actively focused.
- Secure Local Server: Runs on a local HTTPS server with an auto-generated SSL certificate.
- Modern UI: A clean, minimalist interface built with Tailwind CSS, featuring a start/pause control.
- Backend: Go (Golang)
- Frontend: HTML, Tailwind CSS
- AI/ML:
face-api.js(TensorFlow.js)
Follow these steps to get the project running on your local machine.
git clone https://github.com/mohammadhasanii/OculusTrack.git
cd OculusTrackCreate the necessary files and folders with the source code provided below:
main.gostatic/index.htmlstatic/script.js
This command will start the server and automatically generate the required SSL certificate files (localhost.crt & localhost.key) on the first run.
go run main.goThe server will be available at https://localhost:8443.
Modern browsers require a secure https:// connection to access your webcam for privacy reasons. Since this project uses a self-signed certificate, you must manually instruct your operating system to trust it.
You only need to do this once.
- After running the server for the first time, find the generated
localhost.crtfile in your project folder. - Open the Keychain Access application.
- Drag and drop the
localhost.crtfile into the System keychain. - Find the "localhost" certificate in the list, double-click it.
- Expand the "Trust" section.
- Change the "When using this certificate" dropdown to "Always Trust".
- Close the window (you may need to enter your password).
- Restart your browser completely.
- After running the server for the first time, find the generated
localhost.crtfile. - Double-click the
localhost.crtfile. - Click the "Install Certificate..." button.
- Select "Current User" and click Next.
- Choose "Place all certificates in the following store" and click "Browse...".
- Select the "Trusted Root Certification Authorities" store and click OK.
- Click Next, then Finish. Acknowledge the security warning by clicking Yes.
- Restart your browser completely.
- Face Detection: The frontend uses
face-api.jsto detect faces and facial landmarks from the webcam feed. - Gaze Analysis: The application analyzes eye positions and orientations to determine if the user is looking at the screen.
- Time Tracking: When eyes are detected as "focused," the system logs active screen time via API calls to the Go backend.
- Real-time Feedback: The UI provides instant visual feedback showing current focus status and accumulated time.
- Open your browser and navigate to
https://localhost:8443 - Allow camera permissions when prompted
- Click "Start Tracking" to begin eye tracking
- The system will monitor your focus and display real-time statistics
- Use "Pause/Resume" to control tracking as needed
