-
Notifications
You must be signed in to change notification settings - Fork 568
Top Level API
JamesLaskey edited this page Apr 13, 2016
·
15 revisions
Here are all the functions you call to control the operation of WebGazer.
- on include of script in body
- webgazer namespace object introduced
- overwrites any other webgazer data to prevent data contention
- webgazer singleton namespace object
- control functions
- webgazer begin()
- begins collecting click data and activates the camera, should be called as soon as possible to improve accuracy
- attaches window click listener
- starts clock
- video div attached to body
- id = webgazerVideoFeed
- style = invisible
- canvas attached to body
- id = webgazerCanvas
- style = invisible
- returns webgazer object
- webgazer pause()
- stops all webgazer data collection and predictions
- returns webgazer object
- webgazer resume()
- resumes all webgazer data collection and predictions after a pause()
- returns webgazer object
- webgazer end()
- stops all webgazer data collection and predictions and releases all memory being held by the webgazer object.
- Accuracy may suffer if begin is called afterward, consider using pause and resume instead
- IMPORTANT: saves global model data so that user’s returning to the page will have a pre-loaded model
- returns webgazer object
- webgazer showPredictionPoints(boolean)
- if bool is true: shows a circle with the current best guess given by the prediction model
- if bool is false: turns off the prediction circle
- returns webgazer object
- boolean detectCompatibility()
- tests for certain browser requirements that webgazer depends on
- checked again in begin() //TODO
- returns true if browser meets expectations, false otherwise
- webgazer begin()
- setters
- webgazer setTracker( libraryString )
- sets which facial recognition library webgazer should use
- libraryString - a string corresponding to one of the following
- ‘clmtrackr’
- ‘js_objectdetect’
- ‘trackingjs’
- returns webgazer object
- webgazer setRegression( regressionString )
- sets which regression model type webgazer should use
- regressionString - a string corresponding to one of the following
- ‘ridge’
- ‘linear’
- ‘interaction’
- returns webgazer object
- webgazer setGazeListener( callback )
- sets a callback which will be invoked every time webgazer makes a new prediction
- only one callback can be registered at a time, so in multiple calls to setGazeListener only the last callback will remain registered
- callback - function(gazeData, elapsedTime) //TODO this has changed to include results of all regression models
- gazeData - object or null if prediction failed
- x - predicted gaze x screen coordinate in pixels
- y - predicted gaze y screen coordinate in pixels
- elapsedTime - time in milliseconds since begin() was invoked
- gazeData - object or null if prediction failed
- returns webgazer object
- webgazer clearGazeListener()
- removes the current callback
- use this method instead of pause/resume when data should continue to be collected to improve the accuracy
- returns webgazer object
- webgazer setTracker( libraryString )
- getters
- string getTracker()
- gets the current facial recognition library
- returns string - the string corresponding to the library
- getRegression()
- gets the current regression model type
- returns string - the string corresponding to the regression model
- {x:, y:} getCurrentPrediction()
- request a prediction from webgazer
- returns object or null
- x - predicted gaze x screen coordinate in pixels
- y - predicted gaze y screen coordinate in pixels
- string getTracker()