API Docs (Java)
Overview
Name | type | Description |
---|---|---|
GazeTracker | class | A class that generates gaze tracking data |
CameraPosition | class | Information of the screen origin for the camera to be set in GazeTracker |
GazeInfo | class | A class composed of information about eye tracking |
FaceInfo | class | A class composed of information about face. |
UserStatusOption | class | The class contains User Status options information for GazeTracker |
InitializationCallback | interface | A callback interface that notifies the result when creating a gaze tracker |
GazeTrackerCallback | interface | All callbacks used in GazeTracker instance inherit from GazeTrackerCallback |
StatusCallback | interface | An interface that informs whether the Gaze Tracker is operating or not |
GazeCallback | interface | An interface to receive frame-by-frame GazeInfo |
FaceCallback | interface | An interface to receive frame-by-frame FaceInfo |
CalibrationCallback | interface | An interface used in the calibration process |
UserStatusCallback | interface | An interface used for user status function |
ImageCallback | interface | An interface that receives the image buffer from the front camera |
InitializationErrorType | enum | An enum that contains error types of InitializationCallback |
StatusErrorType | enum | An enum that contains error types of StatusCallback |
TrackingState | enum | An enum that contains tracking state types of GazeInfo |
EyeMovementState | enum | An enum that contains eye movement state types using at GazeInfo |
ScreenState | enum | An enum that contains screen state types using at GazeInfo |
CalibrationModeType | enum | An enum that contains calibration mode types of startCalibartion |
AccuracyCriteria | enum | An 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 |
getVersionName
public static String getVersionName()
Parameters | Type | Description |
---|---|---|
versionName | string | SeeSo 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.
Parameters | Type | Description |
---|---|---|
context | android.content.Context | |
licenseKey | String | Key generated from SeeSo console page |
callback | InitializationCallback | Initialized 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.
Parameters | Type | Description |
---|---|---|
context | android.content.Context | |
licenseKey | String | Key generated from SeeSo console page |
callback | InitializationCallback | Initialized after alert Callback |
option | UserStatusOption | It 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, "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.
Parameters | Type | Description |
---|---|---|
gazeTracker | GazeTracker | GazeTracker 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, "YOUR_LICENSE_KEY", initializationCallback);
startTracking
public synchronized 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, "YOUR_LICENSE_KEY", initializationCallback);
stopTracking
public synchronized 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 synchronized 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 Type | Description |
---|---|
boolean | It 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 Type | Description |
---|---|
boolean | if 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.
Parameters | Type | Description |
---|---|---|
cameraPosition | CameraPosition | CameraPosition class |
Example
CameraPosition cameraPosition = new CameraPosition("SM-T720", 1600f, 2560f, -72f, -4f);// tab s5e
tracker.addCameraPosition(cameraPosition);
getCameraPosition
public CameraPosition getCameraPosition()
Return Type | Description |
---|---|
CameraPosition | CameraPosition class |
Example
CameraPosition cameraPosition = tracker.getCameraPosition();
System.out.println(cameraPosition.modelName + " : " + cameraPosition.screenOriginX + " : " + cameraPosition.screenOriginY);
getCameraPositionList
public ArrayList<CameraPosition> getCameraPositionList()
Return Type | Description |
---|---|
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)
Parameters | Type | Description |
---|---|---|
idx | Int | Index of the CameraPosition to use from getCameraPositionList() . |
Example
tracker.selectCameraPosition(0);
setStatusCallback
public void setStatusCallback(StatusCallback callback)
Set StatusCallback implementations to gazeTracker.
Parameters | Type | Description |
---|---|---|
callback | StatusCallback | Callback 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.
Parameters | Type | Description |
---|---|---|
gazeTracker | GazeCallback | Callback 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();
setFaceCallback
public void setFaceCallback(FaceCallback faceCallback)
Set FaceCallback implementations to gazeTracker.
Parameters | Type | Description |
---|---|---|
gazeTracker | FaceCallback | Callback implementation of the FaceCallback |
Example
//implement faceCallback
private FaceCallback faceCallback = new FaceCallback() {
@Override
public void onFace(FaceInfo faceInfo) {
// do something
}
};
gazeTracker.setFaceCallback(faceCallback);
removeFaceCallback
public void removeFaceCallback()
Remove all FaceCallback listeners.
Example
gazeTracker.removeFaceCallback();
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
.
Parameters | Type | Description |
---|---|---|
fps | int | Upper bound of FPS(Frame Per Second) for gaze tracking |
Return Type | Description |
---|---|
boolean | Whether it is applied at the set fps is returned as a result |
Example
gazeTracker.setTrackingFPS(20);
setCameraPreview
public void setCameraPreview(android.view.TextureView cameraPreview)
Parameters | Type | Description |
---|---|---|
cameraPreview | android.view.TextureView | TextureView 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.
Parameters | Type | Description |
---|---|---|
mode | CalibrationModeType | Can select the calibration option. DEFAULT(=FIVE_POINT), ONE_POINT, FIVE_POINT, SIX_POINT |
left | float | Region that needs calibration. The unit is px (default is 80% region of device screen) |
top | float | Region that needs calibration. The unit is px (default is 80% region of device screen) |
right | float | Region that needs calibration. The unit is px (default is 80% region of device screen) |
bottom | float | Region that needs calibration. The unit is px (default is 80% region of device screen) |
criteria | AccuracyCriteria | Option that manage calibration process and accuracy. Three options - DEFAULT, LOW, HIGH - are available. Default is DEFAULT |
Return Type | Description |
---|---|
boolean | It 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 Type | Description |
---|---|
boolean | It 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 Type | Description |
---|---|
boolean | It returns true when calibrating |
setCalibrationData
public boolean setCalibrationData(double[] calibrationData)
Set existing calibration data to gazeTracker.
Parameters | Type | Description |
---|---|---|
calibrationData | double[] | Calibration Data |
Return Type | Description |
---|---|
boolean | Calibration 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.
Parameters | Type | Description |
---|---|---|
callback | CalibrationCallback | Callbacks 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.
Parameters | Type | Description |
---|---|---|
interval | int | Time 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 Type | Description |
---|---|
float | Current Attention score |
setAttentionRegion
public void setAttentionRegion(float left, float top, float right, float bottom)
Set Attention ROI
Parameters | Type | Description |
---|---|---|
left | float | Left boundary of attention region. The unit is px |
top | float | Top boundary of attention region. The unit is px |
right | float | Right boundary of attention region. The unit is px |
bottom | float | Bottom boundary of attention region. The unit is px |
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 Type | Description |
---|---|
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)
Parameters | Type | Description |
---|---|---|
callback | UserStatusCallback | Set 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.
Parameters | Type | Description |
---|---|---|
callback | GazeTrackerCallback | Callbacks 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.
Parameters | Type | Description |
---|---|---|
callback | ImageCallback | Callbacks 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 screenWidth;
public float screenHeight;
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
Variables | type | description |
---|---|---|
modelName | String | Device model name |
screenWidth | float | The current screen width size of the device being used, measured in pixels. |
screenHeight | float | The current screen height size of the device being used, measured in pixels. |
screenOriginX | float | X's Distance from the camera to the top left corner of the screen (mm) |
screenOriginY | float | Y's Distance from the camera to the top left corner of the screen (mm) |
cameraOnLongerAxis | boolean | A 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 float fixationX, fixationY;
public float leftOpenness, rightOpenness;
public TrackingState trackingState;
public EyeMovementState eyeMovementState;
public ScreenState screenState;
}
A class composed of information about eye tracking.
Variables | type | description |
---|---|---|
timestamp | long | Timestamp of gaze point. The unit is millisecond. The time format is UTC |
x | float | x coordinate value of gaze point. Origin is device screen. The unit is pixel(px ) |
y | float | y coordinate value of gaze point. Origin is device screen. The unit is pixel(px ) |
fixationX | float | x coordinate value of last fixation point. Origin is device screen. The unit is pixel(px ) |
fixationY | float | y coordinate value of last fixation point. Origin is device screen. The unit is pixel(px ) |
leftOpenness | float | openness degree of left eye(0.0~1.0). value will only return when userStatusOption in on |
rightOpenness | float | openness degree of right eye(0.0~1.0). value will only return when userStatusOption in on |
trackingState | TrackingState | SUCCESS , LOW_CONFIDENCE , UNSUPPORTED , FACE_MISSING |
eyeMovementState | EyeMovementState | FIXATION , SACCADE , UNKNOWN |
screenState | ScreenState | INSIDE_OF_SCREEN , OUTSIDE_OF_SCREEN , UNKNOWN |
FaceInfo
public class FaceInfo {
public long timestamp;
public float score;
public Size frameSize;
public float left, top, right, bottom;
public float pitch, yaw, roll;
public float centerX, centerY, centerZ;
}
A class composed of information about eye tracking.
Variables | type | description |
---|---|---|
timestamp | long | Timestamp of gaze point. The unit is millisecond. The time format is UTC |
score | float | Value of facial recognition confidence (0.0 ~ 1.0). |
frameSize | android.util.Size | camera frame size. |
left, top, right, bottom | float | It represents the location of the face with a rectangular box. The four sides of the box indicate the four positions of the face within the image. |
pitch | float | Pitch is the rotation around the X-axis of an object. It is also known as the attitude angle. In aviation, it is often referred to as the nose-up or nose-down angle. |
yaw | float | Yaw is the rotation around the Y-axis of an object. It is also known as the heading angle. In aviation, it is often referred to as the bearing or compass angle. |
roll | float | Roll is the rotation around the Z-axis of an object. It is also known as the bank angle. In aviation, it is often referred to as the wing-up or wing-down angle. |
centerX, centerY, centerZ | float | The x,y,z distance of the center of the face from the camera. The unit is mm. |
- When the camera is positioned at the top, we defined it as 0 degrees. (pitch, yaw, roll)
UserStatusOption
public class UserStatusOption
The class contains User Status
options information for GazeTracker
Summary
functions |
---|
isUseAttention |
isUseBlink |
isUseDrowsiness |
useAttention |
useBlink |
useDrowsiness |
useAll |
isUseAttention
isUseBlink
isUseDrowsiness
public boolean isUseAttention()
public boolean isUseBlink()
public boolean isUseDrowsiness()
Return Type | Description |
---|---|
boolean | Return true if the flag is on, false otherwise |
useAttention
useBlink
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.
Parameters | Type | Description |
---|---|---|
tracker | GazeTracker | GazeTracker Instance |
error | InitializationErrorType | Error 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)
Parameters | type | Description |
---|---|---|
error | StatusErrorType | Error 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)
Parameters | Type | Description |
---|---|---|
gazeInfo | GazeInfo | Passing the gaze info value according to the frame |
Example
private GazeCallback gazeCallback = new GazeCallback() {
@Override
public void onGaze(final GazeInfo gazeInfo) {
}
};
gazeTracker.setCallbacks(gazeCallback);
FaceCallback
public interface FaceCallback extends GazeTrackerCallback
Summary
Function |
---|
onFace |
onFace
public void onFace(FaceInfo faceInfo)
Parameters | Type | Description |
---|---|---|
faceInfo | FaceInfo | Passing the face info value according to the frame |
Example
private FaceCallback faceCallback = new FaceCallback() {
@Override
public void onFace(final FaceInfo faceInfo) {
}
};
gazeTracker.setCallbacks(faceCallback);
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.
Parameters | Type | Description |
---|---|---|
x | float | The 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 ) |
y | float | The 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.
Parameters | Type | Description |
---|---|---|
progress | float | Calibration progression for each point |
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.
Parameters | Type | Description |
---|---|---|
calibrationData | double[] | 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
.
-
Attention: How much the user attention is focused on the screen content for
interval
time (0.0 ~ 1.0) -
Drowsiness: If the user feel drowsiness (True/False)
-
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)
- Timestamp range of the data will be passed as
timestampBegin
andtimestampEnd
. - The default time
interval
is30
seconds(see setAttentionInterval). - If the user attention level is low,
score
will be close to 0.0. - If the user attention level is high,
score
will be close to 1.0.
Parameters | Type | Description |
---|---|---|
timestampBegin | long | Beginning Timestamp of the data |
timestampEnd | long | Ending Timestamp of the data |
score | float | User 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, float intensity)
- Timestamp of the data will be passed as
timestamp
. isDrowsiness
istrue
if the user seems drowsy,false
otherwise.intensity
parameter represents the level of drowsiness, ranging from 0 to 1, where a value closer to 0 indicates no drowsiness and a value closer to 1 indicates a high intensity of drowsiness.
Parameters | Type | Description |
---|---|---|
timestamp | long | Timestamp of the data |
isDrowsiness | boolean | User drowsiness flag |
intensity | float | Level of drowsiness intensity (0 to 1) |
Example
private UserStatusCallback userStatusCallback = new UserStatusCallback() {
@Override
public void onDrowsiness(final long timestamp, final boolean isDrowsiness, final float intensity) {
// do something
}
};
gazeTracker.setUserStatusCallback(userStatusCallback);
onBlink
public void onBlink(long timestamp, boolean isBlinkLeft, boolean isBlinkRight, boolean isBlink, float leftOpenness, float rightOpenness)
- Timestamp of the data will be passed as
timestamp
. isBlinkLeft
istrue
if the user blinks their left eye,false
otherwise.isBlinkRight
istrue
if the user blinks their right eye,false
otherwise.isBlink
istrue
if one blinks their eye,false
otherwise(This is a general blink condition).- If the user's eyes are wide open,
leftOpenness
,rightOpenness
inonBlink
callback will be close to 1.0. - If the user's eyes are closed,
leftOpenness
,rightOpenness
inonBlink
callback will be close to 0.0.
Parameters | Type | Description |
---|---|---|
timestamp | long | Timestamp of the data |
isBlinkLeft | boolean | User left blink flag |
isBlinkRight | boolean | User right blink flag |
isBlink | boolean | User blink flag |
leftOpenness | float | User left eye-openness rate |
rightOpenness | float | User right eye-openness rate |
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)
Parameters | Type | Description |
---|---|---|
timestamp | long | Timestamp of the image in milliseconds. The time format is UTC |
image | byte[] | 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
.
Name | Description |
---|---|
ERROR_NONE | Succeed without error |
ERROR_CAMERA_START | GazeTracker.startTracking is called but the front camera of the device is not available |
ERROR_CAMERA_INTERRUPT | The 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.
Name | Description |
---|---|
SUCCESS | Face alignment is in a best position (Gaze tracking success, with valid x and y) |
LOW_CONFIDENCE | Face alignment is not in the best position, but can be used for tracking (Gaze tracking success, with less accurate x and y) |
UNSUPPORTED | Face alignment is not suitable for tracking (Gaze tracking fail, with invalid x and y) |
FACE_MISSING | Face is missing (Gaze tracking fail) |
EyeMovementState
public enum EyeMovementState
Contains eye movement state used at GazeInfo.
Name | Description |
---|---|
FIXATION | Gazes from the past and the gazes up to the present have made a fixation |
SACCADE | Gazes from the past and the gazes up to the present have formed a saccade |
UNKNOWN | Not fixation or saccade |
ScreenState
public enum ScreenState
Contains screen state used at GazeInfo.
Name | Description |
---|---|
INSIDE_OF_SCREEN | Gaze tracking succeeds and the gaze point is inside of the device screen |
OUTSIDE_OF_SCREEN | Gaze tracking succeeds and the gaze point is outside of the device screen |
UNKNOWN | Gaze tracking failed |
CalibrationModeType
public enum CalibrationModeType
Contains calibration mode types of startCalibartion
Name | Description |
---|---|
DEFAULT | Set to the recommended mode. In the current version, Five-point calibration mode |
ONE_POINT | One-point calibration mode |
FIVE_POINT | Five-point calibration mode |
SIX_POINT | Six-point calibration mode |
AccuracyCriteria
public enum AccuracyCriteria
Contains accuracy criteria of startCalibartion.
Name | Description |
---|---|
DEFAULT | Default calibration accuracy criteria |
LOW | Low calibration accuracy criteria |
HIGH | High calibration accuracy criteria |