Skip to main content
Version: Release

API Docs (Java)

note

APIs that doesn't have version tag is version 2.4.0

Overview

NametypeDescription
GazeTracker classA class that generates gaze tracking data
CameraPosition classInformation of the screen origin for the camera to be set in GazeTracker
GazeInfoclassA class composed of information about eye tracking
UserStatusOptionclassThe class contains User Status options information for GazeTracker
InitializationCallbackinterfaceA callback interface that notifies the result when creating a gaze tracker
GazeTrackerCallbackinterfaceAll callbacks used in GazeTracker instance inherit from GazeTrackerCallback
StatusCallbackinterfaceAn interface that informs whether the Gaze Tracker is operating or not
GazeCallbackinterfaceAn interface to receive frame-by-frame GazeInfo
CalibrationCallbackinterfaceAn interface used in the calibration process
UserStatusCallbackinterfaceAn interface used for user status function
ImageCallbackinterfaceAn interface that receives the image buffer from the front camera
InitializationErrorTypeenumAn enum that contains error types of InitializationCallback
StatusErrorTypeenumAn enum that contains error types of StatusCallback
TrackingStateenumAn enum that contains tracking state types of GazeInfo
EyeMovementStateenumAn enum that contains eye movement state types using at GazeInfo
ScreenStateenumAn enum that contains screen state types using at GazeInfo
CalibrationModeTypeenumAn enum that contains calibration mode types of startCalibartion
AccuracyCriteriaenumAn enum that contains accuracy criteria of startCalibartion

GazeTracker

public class GazeTracker

GazeTracker is the class that generates gaze tracking data from the video from the device's front camera.

Summary

Constructor and Destructor
initGazeTracker
initGazeTracker (with User Status Options)
deinitGazeTracker
Functions
getVersionName
startTracking
stopTracking
isTracking
isDeviceFound
addCameraPosition
getCameraPosition
getCameraPositionList
selectCameraPosition
setStatusCallback
removeStatusCallback
setGazeCallback
removeGazeCallback
setTrackingFPS
setCameraPreview
removeCameraPreview
startCalibration
stopCalibration
isCalibrating
startCollectSamples
setCalibrationData
setCalibrationCallback
removeCalibrationCallback
setAttentionInterval
getAttentionScore
setAttentionRegion
getattentionRegion
removeattentionRegion
setUserStatusCallback
removeUserStatusCallback
setCallbacks
setImageCallback
removeImageCallback

getVersionName

public static String getVersionName()
ParametersTypeDescription
versionNamestringSeeSo SDK Version

Example

String version = GazeTracker.getVersionName();
System.out.println("SeeSo version :" + version);

initGazeTracker

public static void initGazeTracker(
Context context, String licenseKey, InitializationCallback callback)

GazeTracker construction process includes authentication.

This Function is asynchronous.

The created GazeTracker instance is delivered through InitializationCallback.

ParametersTypeDescription
contextandroid.content.Context
licenseKeyStringKey generated from SeeSo console page
callbackInitializationCallbackInitialized after alert Callback

Example

// Implement InitializationCallback
InitializationCallback initializationCallback = new InitializationCallback() {
@Override
public void onInitialized(GazeTracker gazeTracker, InitializationErrorType error) {
if (gazeTracker != null) {
// gazeTracker init success
} else {
// gazeTracker init fail
}
}
};

GazeTracker.initGazeTracker(context, "YOUR_LICENSE_KEY", initializationCallback);

initGazeTracker (with User Status Options)

public static void initGazeTracker(Context context, String licenseKey, InitializationCallback callback, UserStatusOption option)

GazeTracker construction requires authentication.

The function is asynchronous.

The created GazeTracker instance is delivered through InitializationCallback.

To use user status option, initialize using UserStatus.

ParametersTypeDescription
contextandroid.content.Context
licenseKeyStringKey generated from SeeSo console page
callbackInitializationCallbackInitialized after alert Callback
optionUserStatusOptionIt contains data about the function among the user status to be used

Example

// Implement InitializationCallback
InitializationCallback initializationCallback = new InitializationCallback() {
@Override
public void onInitialized(GazeTracker gazeTracker, InitializationErrorType error) {
if (gazeTracker != null) {
// gazeTracker init success
} else {
// gazeTracker init fail
}
}
};

UserStatusOption userStatusOption = new UserStatusOption();

if (isStatusAttention) {
userStatusOption.useAttention();
}
if (isStatusBlink) {
userStatusOption.useBlink();
}
if (isStatusDrowsiness) {
userStatusOption.useDrowsiness();
}

GazeTracker.initGazeTracker(context, new CameraPosition(), "YOUR_LICENSE_KEY", initializationCallback, userStatusOption);

deinitGazeTracker

public static void deinitGazeTracker(GazeTracker gazeTracker)

After this is called, do not call gazeTracker's methods.

For memory optimization, assigning null to the destructed object is recommended.

ParametersTypeDescription
gazeTrackerGazeTrackerGazeTracker instance

Example

// Implement InitializationCallback
InitializationCallback initializationCallback = new InitializationCallback() {
@Override
public void onInitialized(GazeTracker gazeTracker, InitializationErrorType error) {
if (gazeTracker != null) {
// gazeTracker init success

// you can deinit gazeTracker instance
GazeTracker.deinitGazeTracker(gazeTracker);
gazeTracker = null;

} else {
// gazeTracker init fail
}
}
};

GazeTracker.initGazeTracker(context, new CameraPosition(), "YOUR_LICENSE_KEY", initializationCallback);

startTracking

public void startTracking()

This function should be called before starting gaze-tracking.

On successful start, StatusCallback.onStarted() is called.

Example

private InitializationCallback initializationCallback = new InitializationCallback() {
@Override
public void onInitialized(GazeTracker gazeTracker, InitializationErrorType error) {
if (gazeTracker != null) {
// gazeTracker init success

// set StatusCallback
gazeTracker.setCallbacks(statusCallback);

// startTracking
gazeTracker.startTracking();

} else {
// gazeTracker init fail
}
}
};

private StatusCallback statusCallback = new StatusCallback() {
@Override
public void onStarted() {
// gazeTracker.startTracking() Success
}

@Override
public void onStopped(final StatusErrorType error) {
// gazeTracker.startTracking() Fail
}
};

GazeTracker.initGazeTracker(context, new CameraPosition(), "YOUR_LICENSE_KEY", initializationCallback);

stopTracking

public void stopTracking()

This function is called to stop gaze tracking.

On successful stop, StatusCallback.onStopped() is called.

Example

// Implement StatusCallback and already set callback to gazeTracker
private StatusCallback statusCallback = new StatusCallback() {
@Override
public void onStarted() {

}

@Override
public void onStopped(final StatusErrorType error) {
// gazeTracker.stopTracking() Success
}
};

gazeTracker.stopTracking();

isTracking

public boolean isTracking()

This function represents the status of gaze tracking. It returns true when gaze tracking is working, false when gaze tracking is stopped.

Return TypeDescription
booleanIt is a return value indicating whether the tracking state is present

Example

boolean isTracking = gazeTracker.isTracking();
System.out.println("Tracking state : " + isTracking);

isDeviceFound

public boolean isDeviceFound()
Return TypeDescription
booleanif it was true, device was founded

Example

boolean isFound = tracker.isDeviceFound();
System.out.println("isDeviceFound " + isFound);

addCameraPosition

public void addCameraPosition(CameraPosition cameraPosition)

Add CameraPosition to GazeTracker instance.

ParametersTypeDescription
cameraPositionCameraPositionCameraPosition class

Example

CameraPosition cameraPosition = new CameraPosition("SM-T720", -72f, -4f);// tab s5e
tracker.addCameraPosition(cameraPosition);

getCameraPosition

public CameraPosition getCameraPosition()
Return TypeDescription
CameraPositionCameraPosition class

Example

CameraPosition cameraPosition = tracker.getCameraPosition();
System.out.println(cameraPosition.modelName + " : " + cameraPosition.screenOriginX + " : " + cameraPosition.screenOriginY);

getCameraPositionList

public ArrayList<CameraPosition> getCameraPositionList()
Return TypeDescription
ArrayList<CameraPosition>ArrayList of CameraPosition of the device. A device can have multiple CameraPosition (ex. Galaxy Fold)

Example

ArrayList<CameraPosition> cameraPositionList = tracker.getCameraPositionList();
for (CameraPosition cameraPosition : cameraPositionList) {
System.out.println(cameraPosition.modelName + " : " + cameraPosition.screenOriginX + " : " + cameraPosition.screenOriginY);
}

selectCameraPosition

public void selectCameraPosition(int idx)
ParametersTypeDescription
idxIntIndex of the CameraPosition to use from getCameraPositionList().

Example

tracker.selectCameraPosition(0);

setStatusCallback

public void setStatusCallback(StatusCallback callback)

Set StatusCallback implementations to gazeTracker.

ParametersTypeDescription
callbackStatusCallbackCallback implementation of the StatusCallback.

Example

//implement statusCallback
gazeTracker.setStatusCallback(statusCallback);

removeStatusCallback

public void removeStatusCallback()

Remove all StatusCallback implementations set in gazeTracker.


setGazeCallback

public void setGazeCallback(GazeCallback callback)

Set GazeCallback implementations to gazeTracker.

ParametersTypeDescription
gazeTrackerGazeCallbackCallback implementation of the GazeCallback

Example

//implement gazeCallback
private GazeCallback gazeCallback = new GazeCallback() {
@Override
public void onGaze(final GazeInfo gazeInfo) {
// do something
}
};

gazeTracker.setGazeCallback(gazeCallback);

removeGazeCallback

public void removeGazeCallback()

Remove all GazeCallback listeners.

Example

gazeTracker.removeGazeCallback();

setTrackingFPS

public boolean setTrackingFPS(int fps)

Limits the maximum FPS of the gaze tracking.
FPS should be between 1 and 30.

FPS can be dropped due to device spec.
The default value is 30.

ParametersTypeDescription
fpsintUpper bound of FPS(Frame Per Second) for gaze tracking
Return TypeDescription
booleanWhether it is applied at the set fps is returned as a result

Example

gazeTracker.setTrackingFPS(20);

setCameraPreview

public void setCameraPreview(android.view.TextureView cameraPreview)
ParametersTypeDescription
cameraPreviewandroid.view.TextureViewTextureView for camera preview

Example

TextureView preview = findViewById(R.id.preview);
gazeTracker.setCameraPreview(preview);

removeCameraPreview

public void removeCameraPreview()

Remove registered camera preview.

Example

gazeTracker.removeCameraPreview();

startCalibration

public boolean startCalibration(CalibrationModeType mode, AccuracyCriteria criteria, float left, float top, float right, float bottom)
public boolean startCalibration(CalibrationModeType mode, float left, float top, float right, float bottom)
public boolean startCalibration(CalibrationModeType mode)
public boolean startCalibration(float left, float top, float right, float bottom)
public boolean startCalibration(AccuracyCriteria criteria)
public boolean startCalibration(CalibrationModeType mode, AccuracyCriteria criteria)
public boolean startCalibration()

It returns true when parameters are valid.

It also returns false when the calibration region has been set outside of the device screen.

The false return will block the calibration process.

ParametersTypeDescription
modeCalibrationModeTypeCan select the calibration option. DEFAULT(=FIVE_POINT), ONE_POINT, FIVE_POINT, SIX_POINT
leftfloatRegion that needs calibration. The unit is px (default is 80% region of device screen)
topfloatRegion that needs calibration. The unit is px (default is 80% region of device screen)
rightfloatRegion that needs calibration. The unit is px (default is 80% region of device screen)
bottomfloatRegion that needs calibration. The unit is px (default is 80% region of device screen)
criteriaAccuracyCriteriaOption that manage calibration process and accuracy. Three options - DEFAULT, LOW, HIGH - are available. Default is DEFAULT
Return TypeDescription
booleanIt returns true when parameters are valid

Example

//implement calibrationCallback
private CalibrationCallback calibrationCallback = new TimeoutCalibrationCallback() {

@Override
public void onCalibrationProgress(final float progress) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// process calibration point UI
}
});
}

@Override
public void onCalibrationNextPoint(final float x, final float y) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// draw calibration point to (x,y)
}
});
handler.postDelayed(new Runnable() {
@Override
public void run() {
// After drawing the calibration point,
// call startCollectSamples after enough time (1,000 ms in this example) that considering user can recognize the point
gaze.startCollectSamples();
}
}, 1000);
}

@Override
public void onCalibrationFinished(double[] calibrationData) {
// saveCalibration(calibrationData);
runOnUiThread(
new Runnable() {
@Override
public void run() {
//remove calibration UI
}
});
}
};

gazeTracker.setCalibrationCallback(calibrationCallback);

// Example of using overloaded functions
boolean startedResult = gazeTracker.startCabliration(CalibrationModeType.ONE_POINT, 100, 100, 1000, 1200);
boolean startedResult = gazeTracker.startCabliration(CalibrationModeType.ONE_POINT);
boolean startedResult = gazeTracker.startCabliration(100, 100, 1000, 1200);
boolean startedResult = gazeTracker.startCabliration();

stopCalibration

public void stopCalibration()

Stop calibration.


isCalibrating

public boolean isCalibrating()

Return true when calibrating, false otherwise.

Return TypeDescription
booleanIt returns true when calibrating

startCollectSamples

public boolean startCollectSamples()

This relays the coordinates of the point that should be seen when calibration is in progress at the function: CalibrationCallback.onCalibrationNextPoint.

You should display coordinates on the screen and call startCollectSamples for calibration.

Return TypeDescription
booleanIt returns true when calibrating

setCalibrationData

public boolean setCalibrationData(double[] calibrationData)

Set existing calibration data to gazeTracker.

ParametersTypeDescription
calibrationDatadouble[]Calibration Data
Return TypeDescription
booleanCalibration Data loaded result

Example

//implement calibrationCallback
private CalibrationCallback calibrationCallback = new TimeoutCalibrationCallback() {

@Override
public void onCalibrationFinished(double[] calibrationData) {
// After calibration is finished, the data is automatically reflected in the current gazeTracker instance.
// You can save it and apply the saved value to the new gazeTracker instance when you restart the app later.
// savedCalibrationData = calibrationData;
}
};

gazeTracker.setCalibrationData(savedCalibrationData);

setCalibrationCallback

public void setCalibrationCallback(CalibrationCallback callback)

Set CalibrationCallback implementations to gazeTracker.

ParametersTypeDescription
callbackCalibrationCallbackCallbacks implementation of the CalibrationCallback

Example

//implement calibrationCallback
private CalibrationCallback calibrationCallback = new TimeoutCalibrationCallback() {

@Override
public void onCalibrationProgress(final float progress) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// process calibration point UI
}
});
}

@Override
public void onCalibrationNextPoint(final float x, final float y) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// draw calibration point to (x,y)
}
});
handler.postDelayed(new Runnable() {
@Override
public void run() {
// After drawing the calibration point,
// call startCollectSamples after enough time (1,000 ms in this example) that considering user can recognize the point
boolean isStart = gaze.startCollectSamples();
}
}, 1000);
}

@Override
public void onCalibrationFinished(double[] calibrationData) {
// saveCalibration(calibrationData);
runOnUiThread(
new Runnable() {
@Override
public void run() {
//remove calibration UI
}
});
}
};

gazeTracker.setCalibrationCallback(calibrationCallback);

removeCalibrationCallback

public void removeCalibrationCallback()

Remove all CalibrationCallback implementations set in gazeTracker.


setAttentionInterval

public void setAttentionInterval(int interval)

Set time interval for the UserStatusCallback.onAttention callback.

The UserStatus Attention score will be calculated for the given time interval.

The beginning and ending timestamps are passed through the onAttention callback as timestampBegin and timestampEnd.

The interval range is 10 to 60 (seconds), and the default value is 30 seconds.

ParametersTypeDescription
intervalintTime interval for the UserStatus Attention score

Example

private InitializationCallback initializationCallback = new InitializationCallback() {
@Override
public void onInitialized(GazeTracker gazeTracker, InitializationErrorType error) {
if (gazeTracker != null) {
// gazeTracker init success
// set StatusCallback

gazeTracker.setCallbacks(statusCallback);
// set UserStatus Attention Interval
gazeTracker.setAttentionInterval(30);
} else {
// gazeTracker init fail
}
}
};

getAttentionScore

public float getAttentionScore()

Get current Attention score from the GazeTracker.

This API does not provide timestamp of the Attention score data.

Use onAttention callback, unless the Attention score is required at a specific time/location.

Return TypeDescription
floatCurrent Attention score

setAttentionRegion

public void setAttentionRegion(float left, float top, float right, float bottom)

Set Attention ROI

ParametersTypeDescription
leftfloatLeft boundary of attention region. The unit is px
topfloatTop boundary of attention region. The unit is px
rightfloatRight boundary of attention region. The unit is px
bottomfloatBottom boundary of attention region. The unit is px
note

Device screen region is set as default.

Example

// Set attention region that (x,y) = (100,100), (width, height) = 100,100
setattentionRegion(100, 100, 200, 200);

getAttentionRegion

public float[] getAttentionRegion()
Return TypeDescription
float[]If the region is not set, returns an empty array. Otherwise, returns left, top, right, bottom passed from setAttentionRegion

removeAttentionRegion

public void removeAttentionRegion()

Remove Attention ROI


setUserStatusCallback

public void setUserStatusCallback(UserStatusCallback callback)
ParametersTypeDescription
callbackUserStatusCallbackSet UserStatusCallback implementations to gazeTracker.

Example

//implement gazeCallback
private UserStatusCallback userStatusCallback = new UserStatusCallback() {
@Override
public void onAttention(final long timestampBegin, final long timestampEnd, final float score) {}

@Override
public void onDrowsiness(final long timestamp, final boolean isDrowsiness) {}

@Override
public void onBlink(final long timestamp, final boolean isBlinkLeft, final boolean isBlinkRight, final boolean isBlink, final float eyeOpenness) {}
};
gazeTracker.setUserStatusCallback(userStatusCallback);

removeUserStatusCallback

public void removeUserStatusCallback()

Remove all UserStatusCallback implementations set in gazeTracker


setCallbacks

public void setCallbacks(GazeTrackerCallback callback...)

Set GazeTrackerCallback implementations to gazeTracker.

ParametersTypeDescription
callbackGazeTrackerCallbackCallbacks implementation of the GazeTrackerCallback.

Example

//implement statusCallback, gazeCallback, imageCallback, calibrationCallback, userStatusCallback
gazeTracker.setCallbacks(statusCallback, gazeCallback, imageCallback, calibrationCallback, userStatusCallback);

setImageCallback

public void setImageCallback(ImageCallback callback)

Set ImageCallback implementations to gazeTracker.

ParametersTypeDescription
callbackImageCallbackCallbacks implementation of the ImageCallback.

Example

//implement imageCallback
private ImageCallback imageCallback = new ImageCallback() {
@Override
public void onImage(long timestamp, final byte[] buffer) {
uiHandler.post(new Runnable() {
@Override
public void run() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
YuvImage yuvImage = new YuvImage(buffer, ImageFormat.NV21, 640, 480, null);
yuvImage.compressToJpeg(new Rect(0, 0, 640, 480), 50, out);
byte[] imageBytes = out.toByteArray();
Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
imgBuffer.setImageBitmap(image);
}
});
}
};
gazeTracker.setImageCallback(imageCallback);

removeImageCallback

public void removeImageCallback()

Remove all ImageCallback implementations set in gazeTracker.


CameraPosition

public class CameraPosition {
public String modelName;
public float screenOriginX;
public float screenOriginY;
public boolean cameraOnLongerAxis;
}

This class indicates the relative position from the camera to the screen origin. GazeTracker uses the information to calculate gaze coordinate.

For more information, see gaze coordinate

Summary

Variablestypedescription
modelNameStringDevice model name
screenOriginXfloatX's Distance from the camera to the top left corner of the screen (mm)
screenOriginYfloatY's Distance from the camera to the top left corner of the screen (mm)
cameraOnLongerAxisbooleanA boolean value representing when the camera is placed on the device's long axis.

GazeInfo

public class GazeInfo {
public long timestamp;
public float x, y;
public TrackingState trackingState;
public EyeMovementState eyeMovementState;
public ScreenState screenState;
}

A class composed of information about eye tracking.

Variablestypedescription
timestamplongTimestamp of gaze point. The unit is millisecond. The time format is UTC
xfloatx coordinate value of gaze point. Origin is device screen. The unit is pixel(px)
yfloaty coordinate value of gaze point. Origin is device screen. The unit is pixel(px)
trackingStateTrackingStateSUCCESS, LOW_CONFIDENCE, UNSUPPORTED, FACE_MISSING
eyeMovementStateEyeMovementStateFIXATION, SACCADE, UNKNOWN
screenStateScreenStateINSIDE_OF_SCREEN, OUTSIDE_OF_SCREEN, UNKNOWN

UserStatusOption

public class UserStatusOption

The class contains User Status options information for GazeTracker

Summary

functions
isUseAttention
isUseBlink
isUseDrowsiness
useAttention
useBlink
useDrowsiness
useAll

isUseAttention

isUseDrowsiness

public boolean isUseAttention()
public boolean isUseBlink()
public boolean isUseDrowsiness()
Return TypeDescription
booleanReturn true if the flag is on, false otherwise

useAttention

useDrowsiness

public void useAttention()
public void useBlink()
public void useDrowsiness()

Set flags.


useAll

public void useAll()

Set All User Status flag.


InitializationCallback

public interface InitailizationCallback

Summary

function
onInitialized

onInitialized

public void onInitailzed(GazeTracker tracker, InitializationErrorType error);

This is callback function being called when GazeTracker.initGazeTracker function has been called.

See Authentication for more details.

ParametersTypeDescription
trackerGazeTrackerGazeTracker Instance
errorInitializationErrorTypeError code

Example

public void onInitialized(GazeTracker tracker, InitializationErrorType error){
if (tracker != null) {
this.tracker = tracker;
} else {
switch (error) {
case InitializationErrorType.ERROR_NONE:
break;
case InitializationErrorType.ERROR_INIT:
break;

...
}
}
}

GazeTrackerCallback

public interface GazeTrackerCallback

Base interface for callbacks.


StatusCallback

public interface StatusCallback extends GazeTrackerCallback

Summary

function
onStarted
onStopped

onStarted

public void onStarted()

The function that automatically called after GazeTracker.startTracking() if initialization succeeds. Calibration is available after this.

Example

@Override
public void onStarted() {
gazeTracker.startCalibration();
}

onStopped

public void onStopped(StatusErrorType error)
ParameterstypeDescription
errorStatusErrorTypeError code

Example

@Override
public void onStopped(StatusErrorType error) {
if (error != StatusCallback.ERROR_NONE) {
// onStopped with error
} else {
// onStopped without error
}
}

GazeCallback

public interface GazeCallback extends GazeTrackerCallback

Summary

Function
onGaze

onGaze

public void onGaze(GazeInfo gazeInfo)
ParametersTypeDescription
gazeInfoGazeInfoPassing the gaze info value according to the frame

Example

private GazeCallback gazeCallback = new GazeCallback() {
@Override
public void onGaze(final GazeInfo gazeInfo) {

}
};

gazeTracker.setCallbacks(gazeCallback);

CalibrationCallback

public interface CalibrationCallback extends GazeTrackerCallback

Summary

Functions
onCalibrationNextPoint
onCalibrationProgress
onCalibrationFinished

onCalibrationNextPoint

public void onCalibrationNextPoint(float x, float y)

The x, y coordinate value of the gaze point that should be focused on during the calibration process.

Also, a proper UI should be on screen for notify the calibration target point.

You should call startCollectSamples to process the calibration.

ParametersTypeDescription
xfloatThe x coordinate value of the gaze point that should be focused on during the calibration process. Origin is the device screen. The unit is pixel(px)
yfloatThe Y coordinate value of the gaze point that should be focused on during the calibration process. Origin is the device screen. The unit is pixel(px)

Example

@Override
public void onCalibrationNextPoint(float x, float y) {
// Draw Calibration Point(x,y) in view.

// than call startCollectSamples to proceed calibration.
gazeTracker.startCollectSamples();
}

onCalibrationProgress

public void onCalibrationProgress(float progress)

This is callback that represent the calibration progression.
The value will be between 0.0 and 1.0.

The value increases when startCollectSamples function is called.

ParametersTypeDescription
progressfloatCalibration progression for each point
note

Visualizing the calibration progression with proper UI is recommended to improve UX.


onCalibrationFinished

public void onCalibrationFinished(double[] calibrationData)

This is callback function that notify when all calibration step finished.

The calibrationData passed as a parameter has already been applied to GazeTracker.

You can save it for later use.

E.g: Not re-calibrating when restarting the app, by passing the stored data via GazeTracker.setCalibrationData.

ParametersTypeDescription
calibrationDatadouble[]Calibration data

Example

public void onCalibrationFinished(double[] calibrationData) {
// remove calibration UI, save calibration data
removeCalibrationUI();
saveCalibrationDataForLaterUse(calibrationData);
}

UserStatusCallback

public interface UserStatusCallback extends GazeTrackerCallback

The User Status includes Attention, Drowsiness, and Blink.

  1. Attention: How much the user attention is focused on the screen content for interval time (0.0 ~ 1.0)

  2. Drowsiness: If the user feel drowsiness (True/False)

  3. Blink: If the user blink eyes (left eye, right eye, general(both eyes))

Summary

Functions
onAttention
onDrowsiness
onBlink

onAttention

  public void onAttention(long timestampBegin, long timestampEnd, float score)
  1. Timestamp range of the data will be passed as timestampBegin and timestampEnd.
  2. The default time interval is 30 seconds(see setAttentionInterval).
  3. If the user attention level is low, score will be close to 0.0.
  4. If the user attention level is high, score will be close to 1.0.
ParametersTypeDescription
timestampBeginlongBeginning Timestamp of the data
timestampEndlongEnding Timestamp of the data
scorefloatUser Attention rate score between the timestamps

Example

private UserStatusCallback userStatusCallback = new UserStatusCallback() {
@Override
public void onAttention(long timestampBegin, long timestampEnd, float score) {
// do something
}
};

gazeTracker.setUserStatusCallback(userStatusCallback);

onDrowsiness

  public void onDrowsiness(long timestamp, boolean isDrowsiness)
  1. Timestamp of the data will be passed as timestamp.
  2. isDrowsiness is true if the user seems drowsy, false otherwise.
ParametersTypeDescription
timestamplongTimestamp of the data
isDrowsinessbooleanUser drowsiness flag

Example

private UserStatusCallback userStatusCallback = new UserStatusCallback() {
@Override
public void onDrowsiness(final long timestamp, final boolean isDrowsiness) {
// do something
}
};

gazeTracker.setUserStatusCallback(userStatusCallback);

public void onBlink(long timestamp, boolean isBlinkLeft, boolean isBlinkRight, boolean isBlink, float eyeOpenness)
  1. Timestamp of the data will be passed as timestamp.
  2. isBlinkLeft is true if the user blinks their left eye, false otherwise.
  3. isBlinkRight is true if the user blinks their right eye, false otherwise.
  4. isBlink is true if one blinks their eye, false otherwise(This is a general blink condition).
  5. If the user's eyes are wide open, eyeOpenness in onBlink callback will be close to 1.0 (not available yet).
  6. If the user's eyes are closed, eyeOpenness in onBlink callback will be close to 0.0 (not available yet).
ParametersTypeDescription
timestamplongTimestamp of the data
isBlinkLeftbooleanUser left blink flag
isBlinkRightbooleanUser right blink flag
isBlinkbooleanUser blink flag
eyeOpennessfloatUser eye-openness rate (N/A)

Example

private UserStatusCallback userStatusCallback = new UserStatusCallback() {
@Override
public void onBlink(final long timestamp, final boolean isBlinkLeft, final boolean isBlinkRight, final boolean isBlink, final float eyeOpenness) {
// do something
}
};

gazeTracker.setUserStatusCallback(userStatusCallback);

ImageCallback

public interface ImageCallback extends GazeTrackerCallback

Front Camera Image buffer callback.

Summary

Functions
onImage

onImage

public void onImage(long timestamp, byte[] image)
ParametersTypeDescription
timestamplongTimestamp of the image in milliseconds. The time format is UTC
imagebyte[]byte[] of image. format is YUV(NV21), width = 640, height = 480

Example

@Override
public void onImage(long timestamp, byte[] image){
try {
File file = new File(yourJpgFilePath);
FileOutputStream out = new FileOutputStream(file);
YuvImage yuvImage = new YuvImage(image, ImageFormat.NV21, 640, 480, null);
yuvImage.compressToJpeg(new Rect(0, 0, 640, 480), 50, out);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}

InitializationErrorType

public enum InitializationErrorType

Contains error types of InitializationCallback.

See Authentication for more details.


StatusErrorType

public enum StatusErrorType

Contains error types of StatusCallback.

NameDescription
ERROR_NONESucceed without error
ERROR_CAMERA_STARTGazeTracker.startTracking is called but the front camera of the device is not available
ERROR_CAMERA_INTERRUPTThe camera stream is disturbed(i.e. used by other applications) or the application running at the background

TrackingState

public enum TrackingState

Contains tracking state used at GazeInfo.

NameDescription
SUCCESSFace alignment is in a best position (Gaze tracking success, with valid x and y)
LOW_CONFIDENCEFace alignment is not in the best position, but can be used for tracking (Gaze tracking success, with less accurate x and y)
UNSUPPORTEDFace alignment is not suitable for tracking (Gaze tracking fail, with invalid x and y)
FACE_MISSINGFace is missing (Gaze tracking fail)

EyeMovementState

public enum EyeMovementState

Contains eye movement state used at GazeInfo.

NameDescription
FIXATIONGazes from the past and the gazes up to the present have made a fixation
SACCADEGazes from the past and the gazes up to the present have formed a saccade
UNKNOWNNot fixation or saccade

ScreenState

public enum ScreenState

Contains screen state used at GazeInfo.

NameDescription
INSIDE_OF_SCREENGaze tracking succeeds and the gaze point is inside of the device screen
OUTSIDE_OF_SCREENGaze tracking succeeds and the gaze point is outside of the device screen
UNKNOWNGaze tracking failed

CalibrationModeType

public enum CalibrationModeType

Contains calibration mode types of startCalibartion

NameDescription
DEFAULTSet to the recommended mode. In the current version, Five-point calibration mode
ONE_POINTOne-point calibration mode
FIVE_POINTFive-point calibration mode
SIX_POINTSix-point calibration mode

AccuracyCriteria

public enum AccuracyCriteria

Contains accuracy criteria of startCalibartion.

NameDescription
DEFAULTDefault calibration accuracy criteria
LOWLow calibration accuracy criteria
HIGHHigh calibration accuracy criteria