Skip to content

Top Level API

JamesLaskey edited this page Apr 8, 2016 · 15 revisions

Here are all the functions you call to control the operation of WebGazer.

  • on include of script in body
  • gazer namespace object introduced
  • overwrites any other gazer data to prevent data contention
  • gazer singleton namespace object
  • functions
    • gazer 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 gazer object
    • gazer pause()
      • stops all gazer data collection and predictions
      • returns gazer object
    • gazer resume()
      • resumes all gazer data collection and predictions after a pause()
      • returns gazer object
    • gazer end()
      • stops all gazer data collection and predictions and releases all memory being held by the gazer 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 gazer object
    • gazer 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 gazer 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
  • setters
    • gazer setTracker( libraryString )
      • sets which facial recognition library gazer should use
      • libraryString - a string corresponding to one of the following
        • ‘clmtrackr’
        • ‘js_objectdetect’
        • ‘trackingjs’
      • returns gazer object
    • gazer setRegression( regressionString )
      • sets which regression model type gazer should use
      • regressionString - a string corresponding to one of the following
        • ‘ridge’
        • ‘linear’
        • ‘interaction’
      • returns gazer object
    • gazer 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
          • x - predicted gaze x screen coordinate in pixels
          • y - predicted gaze y screen coordinate in pixels
          • covariance - 2D confidence covariance matrix //TODO
        • elapsedTime - time in milliseconds since begin() was invoked
      • returns gazer object
    • gazer clearGazeListener()
      • removes the current callback
      • use this method instead of pause/resume when data should continue to be collected to improve the accuracy
      • returns gazer object

getters 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 getCurrentPrediction() request a prediction from gazer returns object x - predicted gaze x screen coordinate in pixels y - predicted gaze y screen coordinate in pixels covariance - 2D confidence covariance matrix

Clone this wiki locally