API Docs
Overview
Name | type | Description |
---|---|---|
EyedidFlutter | class | The main class for utilizing gaze tracking functionality within the eyedid_flutter package. |
GazeTrackerOptions | class | Provides options for configuring the Gaze Tracker. |
GazeTrackerOptionsBuilder | class | A builder class for constructing instances of GazeTrackerOptions. |
CameraPosition | class | Represents the camera position for Android devices. |
InitializedResult | class | Represents the result of the Eyedid GazeTracker initialization. |
MetricsInfo | class | MetricsInfo is designed to collect and structure data from the tracking event stream. |
GazeInfo | class | represents the data collected from gaze tracking events, providing detailed information about the user's gaze and related states. |
FaceInfo | class | represents the data collected from face tracking events, providing information about the detected face and its orientation in space. |
BlinkInfo | class | represents the data related to eye blink detection, providing information about whether a blink occurred and the openness level of each eye. |
UserStatusInfo | class | provides information about the user's status, such as drowsiness and attention level, based on gaze and eye tracking data. |
StatusInfo | class | A class representing status information obtained from a status event. |
CalibrationInfo | class | A class that represents calibration status information for the Eyedid SDK. |
OneEuroFilterManager | class | Manages a collection of OneEuroFilters for filtering multiple values. |
CalibrationMode | enum | An enumeration representing the calibration modes for calibration processes. |
CalibrationCriteria | enum | An enum representing different calibration criteria or levels. |
TrackingState | enum | Enum representing different states of gaze tracking. |
EyeMovementState | enum | An enumeration representing different types of eye movement states. |
ScreenState | enum | An enumeration representing different states of gaze position in relation to the device screen. |
StatusType | enum | An enumeration representing different types of status events for gaze tracking. |
StatusErrorType | enum | An enumeration representing different types of error scenarios when the gaze tracking status stops. |
CalibrationType | enum | An enumeration representing the different stages within a calibration process. |
EyedidDeviceOrientation | enum | An enumeration representing different types of gaze events orientation that can be tracked. |
EyedidFlutter
class EyedidFlutter
The EyedidFlutter
class is the main interface for integrating gaze tracking and calibration features using the Eyedid SDK
in a Flutter application.
This class provides methods for initializing the SDK, starting and stopping gaze tracking, and accessing various events related to gaze tracking and calibration.
Summary
Function | Camera Permission Required | Description |
---|---|---|
checkCameraPermission | No | Checks if the camera permission is granted for the Eyedid SDK. |
requestCameraPermission | No | Requests camera permission and returns whether the permission is granted. |
initGazeTracker | Yes | Initializes the GazeTracker with the given license key and options. |
releaseGazeTracker | Yes | Releases the GazeTracker resources. |
getPlatformVersion | No | Retrieves the version of the Eyedid SDK for the current platform. |
startTracking | Yes | Starts the gaze tracking process. |
stopTracking | Yes | Stops the ongoing gaze tracking process. |
isTracking | No | Checks if gaze tracking is currently active. |
hasCameraPositions | No | Checks if the required device information is available for the Eyedid SDK(Android only). |
addCameraPosition | No | Adds camera position information to the Eyedid SDK(Android only). |
getCameraPosition | No | Retrieves the current camera position used by the Eyedid SDK(Android only). |
getCameraPositionList | No | Retrieves the list of current camera positions used by the Eyedid SDK(Android only). |
selectCameraPosition | No | Selects a specific camera position in the Eyedid SDK by index(Android only). |
setTrackingFPS | No | Sets the frames per second (FPS) for gaze tracking in the Eyedid SDK. |
startCalibration | No | Initiates the calibration process in the Eyedid SDK. |
stopCalibration | No | Stops the current calibration process in the Eyedid SDK. |
isCalibrating | No | Checks if the Eyedid SDK is currently performing calibration. |
startCollectSamples | No | Informs the Eyedid SDK to start collecting samples for the current calibration target. |
setCalibrationData | No | Sets calibration data in the Eyedid SDK for refinement. |
setAttentionRegion | No | Sets the region of interest (ROI) for the Attention feature in the Eyedid SDK. |
getAttentionRegion | No | Retrieves the currently set region of interest (ROI) for the Attention feature. |
removeAttentionRegion | No | Removes the region of interest (ROI) for the Attention feature. |
setForcedOrientation | No | Manually changes the device orientation in the Eyedid SDK (iOS only). |
resetForcedOrientation | No | Resets the forced orientation in the Eyedid SDK (iOS only). |
getTrackingEvent | No | Returns an event stream that provides camera tracking data. |
getCalibrationEvent | No | Returns a stream of calibration events from the Eyedid SDK. |
getStatusEvent | No | Returns an event stream that provides status updates for the Eyedid GazeTracker. |
checkCameraPermission
Future<bool> checkCameraPermission() async
Checks if the camera permission is granted for the Eyedid SDK
.
This function asynchronously checks whether the camera permission is granted for the Eyedid SDK
.
Return Type | Description |
---|---|
Future<bool> | true if the camera permission has been granted. false if the camera permission has not been granted or is denied. |
Example
_hasCameraPermission = await _eyedidFlutterPlugin.checkCameraPermission();
if(!_hasCameraPermission) {
print("Camera permission is not granted. Please enable camera access in the device settings.");
}
requestCameraPermission
Future<bool> requestCameraPermission() async
Requests camera permission and returns whether the permission is granted. This function asynchronously requests camera permission from the user.
Return Type | Description |
---|---|
Future<bool> | true if the user grants the camera permission. false if the user denies the camera permission or if the permission was previously denied. |
Example
_hasCameraPermission = await _eyedidFlutterPlugin.checkCameraPermission();
if(!_hasCameraPermission) {
_hasCameraPermission =
await _eyedidFlutterPlugin.requestCameraPermission();
}
initGazeTracker
FutureOr<InitializedResult?> initGazeTracker(
{required String licenseKey, GazeTrackerOptions? options})
Initializes the GazeTracker with the given license key and options.
This function asynchronously initializes the GazeTracker using the provided licenseKey
and optional options
. If no options are provided, default options are created using GazeTrackerOptionsBuilder.
Parameters | Type | Description |
---|---|---|
licenseKey | String | licenseKey is required and used to authorize the GazeTracker. |
options | GazeTrackerOptions? | options are the optional configuration settings for the GazeTracker. If null ,default options are used. |
Return Type | Description |
---|---|
FutureOr<InitializedResult?> | Returns a FutureOr containing an InitializedResult, which provides information on whether the initialization was successful or not. If the result is null, the initialization failed or was interrupted. |
Example
final options = GazeTrackerOptionsBuilder()
.setPreset(CameraPreset.vga640x480)
.setUseGazeFilter(false)
.setUseBlink(false)
.setUseUserStatus(false)
.build();
final result = await _eyedidFlutterPlugin.initGazeTracker(licenseKey: _licenseKey, options: options);
releaseGazeTracker
Future<void> releaseGazeTracker() async
Releases the GazeTracker resources. This function asynchronously releases all resources associated with the GazeTracker. It should be called when the GazeTracker is no longer needed to free up memory and system resources.
Example
final isTracking = await _eyedidFlutterPlugin.isTracking();
if(!isTracking) {
await _eyedidFlutter.releaseGazeTracker();
print("Released Eyedid.")
}
getPlatformVersion
Future<String?> getPlatformVersion()
Retrieves the version of the Eyedid SDK
for the current platform.
This method returns the version of the Eyedid eye-tracking module for the
specific platform (iOS/Android). The version string provides insight into
the currently installed release of the Eyedid SDK
.
Return Type | Description |
---|---|
Future<String?> | Returns a Future that resolves with the version string, or null if the version cannot be retrieved. |
Example
try {
platformVersion = await _eyedidFlutterPlugin.getPlatformVersion() ?? 'Unknown platform version';
} on PlatformException catch (error) {
print(error);
platformVersion = 'Failed to get platform version.';
}
startTracking
Future<void> startTracking() async
Starts the gaze tracking process.
This function initiates tracking of the user's gaze. Before calling this function,
ensure that the gaze tracker has been initialized using initGazeTracker.
If the camera permission has not been granted or if the gaze tracker has not been
initialized correctly, this function may throw a PlatformException
.
Example
final initialized = await _eyedidFlutterPlugin.initGazeTracker(licenseKey: _licenseKey, options: options);
if (initialized != null && initialized.result == true) {
_eyedidFlutterPlugin.startTracking();
}
stopTracking
Future<void> stopTracking() async
Stops the ongoing gaze tracking process. This function halts the current gaze tracking operation. Before calling this function, ensure that the gaze tracker has been initialized using initGazeTracker.
Throws a PlatformException
if the camera permission is not granted or if the gaze tracker
has not been properly initialized.
Example
try {
_eyedidFlutterPlugin.stopTracking(); // Call the function to stop tracking
} on PlatformException catch (e) {
setState(() {
_stateString = "Occur PlatformException (${e.message})";
});
}
isTracking
Future<bool?> isTracking() async
Checks if gaze tracking is currently active.
Return Type | Description |
---|---|
Future<bool?> | true if tracking is active. false if tracking is inactive or not properly initialized. |
Example
final isTracking = await _eyedidFlutterPlugin.isTracking() ?? false;
setState(() {
_showGaze = isTracking;
});
hasCameraPositions
Future<bool?> hasCameraPositions() async
This function is Android-specific.
Checks if the required device information is available for the Eyedid SDK. Determines if the necessary device information is present for optimal gaze tracking.
Return Type | Description |
---|---|
Future<bool?> | true if the device information is available. false if it is not available. |
Example
final hasCameraPositions = await _eyedidFlutterPlugin.hasCameraPositions() ?? false;
if(!hasCameraPositions) {
print("Camera position information is missing, which may affect the accuracy of gaze tracking.");
}
addCameraPosition
Future<void> addCameraPosition(CameraPosition cameraPosition) async
This function is Android-specific.
Adds camera position information to the Eyedid SDK. Provides the necessary camera position data to improve gaze tracking accuracy. The cameraPosition parameter contains the relevant data.
Parameters | Type | Description |
---|---|---|
cameraPosition | CameraPosition | The camera position data. |
Example
final custom = CameraPosition(modelName: "CustomDevice", screenWidth: 1280, screenHeight: 1920, screenOriginX: -35, screenOriginY: 5, cameraOnLongerAxis: false);
await _eyedidFlutterPlugin.addCameraPosition(custom);
getCameraPositions
Future<CameraPosition?> getCameraPosition() async
This function is Android-specific.
Retrieves the current camera position used by the Eyedid SDK.
Return Type | Description |
---|---|
Future[CameraPosition?] | currently in use, or null if unavailable. |
Example
final current = await _eyedidFlutterPlugin.getCameraPosition();
if(current != null) {
print("current camera position [${current.toString()}]");
}
getCameraPositionList
Future<List<CameraPosition>?> getCameraPositionList() async
This function is Android-specific.
Retrieves the list of current camera positions used by the Eyedid SDK.
Return Type | Description |
---|---|
Future<List<CameraPosition>> | Returns a list of CameraPosition objects, or null if unavailable. |
Example
final currentList = await _eyedidFlutterPlugin.getCameraPositionList();
if(currentList != null) {
for(var cp in currentList) {
print("current camera position [${cp.toString()}]");
}
}
selectCameraPosition
Future<void> selectCameraPosition(int idx) async
This function is Android-specific.
Selects a specific camera position in the Eyedid SDK by index.
Chooses a camera position from the available list using the provided idx
.
Parameters | Type | Description |
---|---|---|
idx | int | The index of the camera position to select. |
Example
final screenSize = MediaQuery.of(context).size;
final screenWidth = screenSize.width;
final screenHeight = screenSize.height;
// Example: Galaxy Fold's default screen resolution conditions
if (screenWidth == 1768 && screenHeight == 2208) {
// Using the internal main screen
await _eyedidFlutterPlugin.selectCameraPosition(0); // Main camera position
print("Main camera position selected for Galaxy Fold (Main Screen).");
} else if (screenWidth == 832 && screenHeight == 2260) {
// Using the external cover screen
await _eyedidFlutterPlugin.selectCameraPosition(1); // Cover camera position
print("Cover camera position selected for Galaxy Fold (Cover Screen).");
}
setTrackingFPS
Future<bool?> setTrackingFPS(int fps) async
Sets the frames per second (FPS) for gaze tracking in the Eyedid SDK. Specifies the desired FPS for gaze tracking. By default, the FPS is set to 30 for the front camera, but higher values can be set if supported by the device.
Parameters | Type | Description |
---|---|---|
fps | int | The desired frames per second for gaze tracking. |
Return Type | Description |
---|---|
Future<bool?> | true if the FPS is successfully updated. false if the FPS is out of range (below 1) or if an error occurs. |
Example
final result = await _eyedidFlutterPlugin.setTrackingFPS(15) ?? false;
if (result) {
print("Tracking FPS set to 15 successfully.");
}
startCalibration
Future<void> startCalibration(CalibrationMode calibrationMode,
{CalibrationCriteria calibrationCriteria = CalibrationCriteria.standard,
Rect? region}) async
Initiates the calibration process in the Eyedid SDK.
Parameters | Type | Description |
---|---|---|
calibrationMode | CalibrationMode | The mode to use (1, 5 targets). |
calibrationCriteria | CalibrationCriteria | The criteria for calibration (default is CalibrationCriteria.standard). |
region | Rect? | The screen region where targets will appear (default is the full screen). |
Example
// 5 point target calibration
_eyedidFlutterPlugin.startCalibration(CalibrationMode.five);
stopCalibration
Future<void> stopCalibration() async
Stops the current calibration process in the Eyedid SDK.
Any progress made before stopping will not be saved.
Example
await _eyedidFlutterPlugin.stopCalibration();
setState(() {
_calibrationShowing = false;
});
isCalibrating
Future<bool?> isCalibrating() async
Checks if the Eyedid SDK is currently performing calibration.
Return Type | Description |
---|---|
Future<bool?> | true if calibration is in progress. false if calibration is not active or if an error occurs. |
Example
final isCalibrating = await _eyedidFlutterPlugin.isCalibrating() ?? false;
if (isCalibrating) {
await _eyedidFlutterPlugin.stopCalibration();
setState(() {
_calibrationShowing = false;
});
}
startCollectSamples
Future<void> startCollectSamples() async
Informs the Eyedid SDK to start collecting samples for the current calibration target. Call this function when the calibration target is displayed on the UI and you are ready to collect calibration data.
Example
_eyedidFlutterPlugin.getCalibrationEvent().listen((event) {
final info = CalibrationInfo(event);
if (info.type == CalibrationType.nextPoint) {
setState(() {
_nextX = info.next!.x;
_nextY = info.next!.y;
_calibrationProgress = 0.0;
});
Future.delayed(const Duration(milliseconds: 500), () {
_eyedidFlutterPlugin.startCollectSamples();
});
}
});
setCalibrationData
Future<void> setCalibrationData(List<double> data) async
Sets calibration data in the Eyedid SDK for refinement.
Provides the Eyedid SDK with calibration data for adjustment or refinement.
Parameters | Type | Description |
---|---|---|
data | List<double> | A list of doubles containing the calibration data. |
Example
final data = await loadCalibrationData();
await _eyedidFlutterPlugin.setCalibrationData(data);
setAttentionRegion
Future<void> setAttentionRegion(Rect region) async
Sets the region of interest (ROI) for the Attention feature in the Eyedid SDK.
Parameters | Type | Description |
---|---|---|
region | Rect | specifies the area of interest as a [Rect] on the device screen. |
Example
// roi is x : 10, y : 10, width : 100, height : 100
Rect roi = Rect(10, 10, 100, 100);
await _eyedidFlutterPlugin.setAttentionRegion(roi);
getAttentionRegion
Future<Rect?> getAttentionRegion() async
Retrieves the currently set region of interest (ROI) for the Attention feature.
Return Type | Description |
---|---|
Future<Rect?> | current Rect representing the ROI, or null if not set. |
Example
final roi = await _eyedidFlutterPlugin.setAttentionRegion();
if (roi != null) {
print("roi is ${roi.toString()}");
}
removeAttentionRegion
Future<void> removeAttentionRegion() async
Removes the region of interest (ROI) for the Attention feature.
After removal, attention-related information will no longer be provided.
Example
final roi = await _eyedidFlutterPlugin.setAttentionRegion();
if (roi != null) {
await _eyedidFlutterPlugin.removeAttentionRegion();
}
setForcedOrientation
Future<bool?> setForcedOrientation(EyedidDeviceOrientation orientation) async
This function is iOS-specific.
Manually changes the device orientation in the Eyedid SDK
Parameters | Type | Description |
---|---|---|
orientation | EyedidDeviceOrientation | Changes the device orientation using EyedidDeviceOrientation. |
Return Type | Description |
---|---|
Future<bool?> | true if successful. false if failed or unsupported. |
Example
final result = await _eyedidFlutterPlugin.setForcedOrientation(EyedidDeviceOrientation.portrait) ?? false;
if (result){
print("set portrait orientation.")
}
resetForcedOrientation
Future<bool?> resetForcedOrientation() async
This function is iOS-specific.
Resets the forced orientation in the Eyedid SDK.
After calling, the device's orientation will revert to automatic.
Return Type | Description |
---|---|
Future<bool?> | true if the reset was successful. false if failed or unsupported. |
Example
await _eyedidFlutterPlugin.resetForcedOrientation();
getTrackingEvent
Stream<dynamic> getTrackingEvent()
Returns an event stream that provides camera tracking data.
This stream delivers real-time tracking matrix information from the camera. Subscribe to the stream to process tracking data.
Example
_eyedidFlutterPlugin.getTrackingEvent().listen((event) {
final info = MetricsInfo(event);
if (info.gazeInfo.trackingState == TrackingState.success) {
setState(() {
_x = info.gazeInfo.gaze.x;
_y = info.gazeInfo.gaze.y;
_gazeColor = Colors.green;
});
} else {
setState(() {
_gazeColor = Colors.red;
});
}
});
getCalibrationEvent
Stream<dynamic> getCalibrationEvent()
Returns a stream of calibration events from the Eyedid SDK.
The stream provides updates about the calibration process through
CalibrationEvent
objects, allowing subscribers to receive real-time
calibration data.
Consumers can listen to this stream to track calibration progress or changes.
Example
_eyedidFlutterPlugin.getCalibrationEvent().listen((event) {
final info = CalibrationInfo(event);
if (info.type == CalibrationType.nextPoint) {
setState(() {
_nextX = info.next!.x;
_nextY = info.next!.y;
_calibrationProgress = 0.0;
});
Future.delayed(const Duration(milliseconds: 500), () {
_eyedidFlutterPlugin.startCollectSamples();
});
} else if (info.type == CalibrationType.progress) {
setState(() {
_calibrationProgress = info.progress!;
});
} else if (info.type == CalibrationType.finished) {
setState(() {
_isCaliMode = false;
});
}
});
getStatusEvent
Stream<dynamic> getStatusEvent()
Returns an event stream that provides status updates for the Eyedid GazeTracker.
This stream notifies when the tracking starts or stops, providing real-time updates on the GazeTracker's status.
Example
_eyedidFlutterPlugin.getStatusEvent().listen((event) {
final info = StatusInfo(event);
if (info.type == StatusType.start) {
setState(() {
_stateString = "start Tracking";
_showingGaze = true;
});
} else {
setState(() {
_stateString = "stop Trakcing : ${info.errorType?.name}";
_showingGaze = false;
});
}
});
GazeTrackerOptions
class GazeTrackerOptions {
final bool useBlink;
final bool useUserStatus;
final bool useGazeFilter;
final int maxConcurrency;
final CameraPreset preset;
// Returns a new [GazeTrackerOptionsBuilder] to configure the options.
static GazeTrackerOptionsBuilder get builder => GazeTrackerOptionsBuilder();
}
Provides options for configuring the Gaze Tracker.
Use GazeTrackerOptions.builder
to customize options such as blink detection,
user status tracking, gaze filtering, concurrency control, and camera presets.
Example
var options = GazeTrackerOptions.builder
.setUseBlink(true)
.setMaxConcurrency(2)
.setPreset(CameraPreset.fhd1920x1080)
.build();
GazeTrackerOptionsBuilder
class GazeTrackerOptionsBuilder
A builder class for constructing instances of GazeTrackerOptions. The GazeTrackerOptionsBuilder provides a fluent interface for configuring the options used by the gaze tracker. This includes settings such as blink detection, user status tracking, gaze filtering, concurrency limits, and camera presets.
default parameters.
- _useBlink = false;
- _useUserStatus = false;
- _useGazeFilter = true;
- _maxConcurrency = 4;
- CameraPreset _preset = CameraPreset.vga640x480;
Summary
Function | Description | Return Type |
---|---|---|
build | Builds the GazeTrackerOptions instance with the specified settings. | GazeTrackerOptions |
setCameraPreset | Sets the camera resolution preset to be used for gaze tracking. | GazeTrackerOptionsBuilder |
setMaxConcurrency | Sets the maximum number of concurrent threads allowed for processing. | GazeTrackerOptionsBuilder |
setUseBlink | Sets whether to enable blink detection. | GazeTrackerOptionsBuilder |
setUseUserStatus | Sets whether to enable user status tracking (e.g., focus, drowsiness). | GazeTrackerOptionsBuilder |
setUseGazeFilter | Sets whether to apply a gaze filter to stabilize gaze tracking data. | GazeTrackerOptionsBuilder |
build
GazeTrackerOptions build()
Builds and returns a GazeTrackerOptions instance with the configured settings. This method finalizes the configuration and returns an instance of GazeTrackerOptions.
Example
var options = GazeTrackerOptionsBuilder().build();
setCameraPreset
GazeTrackerOptionsBuilder setPreset(CameraPreset preset)
Sets the camera preset for the gaze tracker.
Parameters | Type | Description |
---|---|---|
preset | CameraPreset | The camera resolution preset to use. |
Return Type | Description |
---|---|
GazeTrackerOptionsBuilder | The GazeTrackerOptionsBuilder instance for method chaining. |
Example
var options = GazeTrackerOptionsBuilder()
.setPreset(CameraPreset.fhd1920x1080)
build();
setMaxConcurrency
GazeTrackerOptionsBuilder setMaxConcurrency(int maxConcurrency)
Sets the maximum number of concurrent gaze tracking processes.
Parameters | Type | Description |
---|---|---|
maxConcurrency | int | specifies the maximum number of threads to be used for gaze tracking. |
If maxConcurrency
is 0, it will use as many threads as possible without limitation.
If maxConcurrency
is less than 1, it defaults to 1.
Return Type | Description |
---|---|
GazeTrackerOptionsBuilder | The GazeTrackerOptionsBuilder instance for method chaining. |
Example
var options = GazeTrackerOptionsBuilder()
.setMaxConcurrency(4)
.setPreset(CameraPreset.fhd1920x1080)
build();
setUseBlink
GazeTrackerOptionsBuilder setUseBlink(bool useBlink)
Sets whether to use the blink detection feature.
Parameters | Type | Description |
---|---|---|
useBlink | bool | useBlink determines if the blink detection feature should be enabled. |
Return Type | Description |
---|---|
GazeTrackerOptionsBuilder | The GazeTrackerOptionsBuilder instance for method chaining. |
Example
var options = GazeTrackerOptionsBuilder()
.setUseBlink(true)
.setMaxConcurrency(4)
.setPreset(CameraPreset.fhd1920x1080)
build();
setUseUserStatus
GazeTrackerOptionsBuilder setUseUserStatus(bool useUserStatus)
Sets whether to use user status tracking.
Parameters | Type | Description |
---|---|---|
useUserStatus | bool | useUserStatus determines if the user status tracking should be enabled. |
Return Type | Description |
---|---|
GazeTrackerOptionsBuilder | The GazeTrackerOptionsBuilder instance for method chaining. |
Example
var options = GazeTrackerOptionsBuilder()
.setUseUserStatus(true)
.setUseBlink(true)
.setMaxConcurrency(4)
.setPreset(CameraPreset.fhd1920x1080)
build();
setUseGazeFilter
GazeTrackerOptionsBuilder setUseGazeFilter(bool useGazeFilter)
Sets whether to use gaze filtering for stabilization.
Parameters | Type | Description |
---|---|---|
useGazeFilter | bool | useGazeFilter determines if gaze filtering should be applied to the tracking data. |
Return Type | Description |
---|---|
GazeTrackerOptionsBuilder | The GazeTrackerOptionsBuilder instance for method chaining. |
Example
var options = GazeTrackerOptionsBuilder()
.setUseGazeFilter(false)
.setUseUserStatus(true)
.setUseBlink(true)
.setMaxConcurrency(4)
.setPreset(CameraPreset.fhd1920x1080)
build();
CameraPosition
class CameraPosition {
final String modelName;
final double screenWidth;
final double screenHeight;
final double screenOriginX;
final double screenOriginY;
final bool cameraOnLongerAxis;
}
Represents the camera position for Android devices
.
This class provides the necessary device information for accurate gaze tracking on Android
.
Variables | type | description |
---|---|---|
modelName | String | The name of the device model. |
screenWidth | double | The width of the screen. |
screenHeight | double | The height of the screen. |
screenOriginX | double | The distance between the center of the camera and the top-left corner of the screen along the x-axis (in mm). Positive values represent the right direction. |
screenOriginY | double | The distance between the center of the camera and the top-left corner of the screen along the y-axis (in mm). Positive values represent the upward direction. |
cameraOnLongerAxis | bool | bool value indicating whether the camera is located along the longer axis of the device. |
Constructor
CameraPosition({
required this.modelName,
required this.screenWidth,
required this.screenHeight,
required this.screenOriginX,
required this.screenOriginY,
this.cameraOnLongerAxis = false,
});
Constructor to initialize the camera position
Parameters | Type | Description |
---|---|---|
modelName | String | The name of the device model. |
screenWidth | double | The width of the screen (in pixels). |
screenHeight | double | The height of the screen (in pixels). |
screenOriginX | double | The x-axis distance from the camera to the top-left corner of the screen (in mm). |
screenOriginY | double | The y-axis distance from the camera to the top-left corner of the screen (in mm). |
cameraOnLongerAxis | bool | A bool indicating if the camera is on the longer axis of the device. |
Example
final cameraPosition = CameraPosition(
modelName: "SM-T720",
screenWidth: 1600,
screenHeight: 2560,
screenOriginX: -72,
screenOriginY: -4); // galaxy tab
InitializedResult
class InitializedResult {
late bool result;
late String message;
static const String isAlreadyAttempting = "Already attempting";
static const String gazeTrackerAlreadyInitialized = "Gaze tracker is already initialized.";
}
Represents the result of the Eyedid GazeTracker initialization. Use this class to obtain the result of the initialization process after calling initGazeTracker.
Variables | type | description |
---|---|---|
result | bool | Whether the initialization was successful. |
message | String | Additional information in case of failure. (If initialization is successful, this will be "ERROR_NONE.") |
isAlreadyAttempting | String | Initialization is already in progress. |
gazeTrackerAlreadyInitialized | String | Gaze tracker is already initialized. |
Example
final result = await _eyedidFlutterPlugin.initGazeTracker(
licenseKey: _licenseKey, options: options);
if (result != null) {
_eyedidFlutterPlugin.startTracking();
} else if (result.message == InitializedResult.isAlreadyAttempting ||
result.message == InitializedResult.gazeTrackerAlreadyInitialized) {
final isTracking = await _eyedidFlutterPlugin.isTracking() ?? false;
if (isTracking) {
showGaze = true;
}
}
MetricsInfo
class MetricsInfo {
late final int timestamp;
late final GazeInfo gazeInfo;
late final FaceInfo faceInfo;
late final BlinkInfo blinkInfo;
late final UserStatusInfo userStatusInfo;
}
MetricsInfo is a data structure designed to collect and organize various information from the tracking event stream.
Variables | type | description |
---|---|---|
timestamp | int | The timestamp of the event. |
gazeInfo | GazeInfo | Information about the user's gaze, such as coordinates and tracking state. |
faceInfo | FaceInfo | Details regarding the user's face position and orientation. |
blinkInfo | BlinkInfo | Blink detection data. |
userStatusInfo | UserStatusInfo | Additional status information about the user, such as attention level. |
GazeInfo
class GazeInfo {
late final Point<double> gaze;
late final Point<double> fixation;
late final TrackingState trackingState;
late final EyemovementState eyemovementState;
late final ScreenState screenState;
}
GazeInfo represents the data collected from gaze tracking events, providing detailed information about the user's gaze and related states. GazeInfo is essential for interpreting the user's gaze behavior and determining their interaction with the screen in real-time.
Variables | type | description |
---|---|---|
gaze | Point<double> | The current gaze point on the screen, represented as coordinates (x, y). |
fixation | Point<double> | The most recently detected fixation point, providing stable coordinates where the user's gaze was fixated. |
trackingState | TrackingState | The state of the gaze tracking, indicating whether tracking is successful, failed. |
eyemovementState | EyemovementState | Information about the user's eye movement, such as fixation or saccade. |
screenState | ScreenState | Indicates whether the user's gaze is within the device screen boundaries or outside of it. |
FaceInfo
class FaceInfo {
late final double score;
late final Rect rect;
late final Size imageSize;
late final double pitch;
late final double yaw;
late final double roll;
late final double centerX;
late final double centerY;
late final double centerZ;
}
FaceInfo represents the data collected from face tracking events, providing information about the detected face and its orientation in space. FaceInfo is useful for understanding the face orientation and its position relative to the camera, aiding in gaze tracking and other facial interactions.
Variables | type | description |
---|---|---|
score | double | A confidence score (0.0 to 1.0) indicating the accuracy of the face detection. |
rect | Rect | The bounding rectangle of the detected face, represented as a Rect object with coordinates relative to imageSize . |
imageSize | Size | The size of the image used by the camera during face detection, represented as a Size object. |
pitch | double | The pitch angle of the face, representing the up and down tilt. |
yaw | double | The yaw angle of the face, representing the left and right rotation. |
roll | double | The roll angle of the face, representing the tilt to the left or right side. |
centerX | double | The distance of the face's center from the camera along the X-axis. (Unit is mm) |
centerY | double | The distance of the face's center from the camera along the Y-axis. (Unit is mm) |
centerZ | double | The distance of the face's center from the camera along the Z-axis. (Unit is mm) |
BlinkInfo
class BlinkInfo {
late final bool isBlink;
late final bool isBlinkLeft;
late final bool isBlinkRight;
late final double leftOpenness;
late final double rightOpenness;
}
BlinkInfo represents the data related to eye blink detection, providing information about whether a blink occurred and the openness level of each eye. BlinkInfo is used to monitor and interpret the blinking state of the user's eyes, aiding in detecting attention levels and gaze-based interactions.
Variables | type | description |
---|---|---|
isBlink | bool | A boolean value indicating whether a blink (both eyes) is detected. |
isBlinkLeft | bool | A boolean value indicating whether the left eye is detected as blinking. |
isBlinkRight | bool | A boolean value indicating whether the right eye is detected as blinking. |
leftOpenness | double | A double value (0.0 to 1.0) representing the openness level of the left eye, where 0.0 means fully closed and 1.0 means fully open. |
rightOpenness | double | A double value (0.0 to 1.0) representing the openness level of the right eye, where 0.0 means fully closed and 1.0 means fully open. |
UserStatusInfo
class UserStatusInfo {
late final bool isDrowsy;
late final double drowsinessIntensity;
late final double attentionScore;
}
UserStatusInfo provides information about the user's status, such as drowsiness and attention level, based on gaze and eye tracking data. UserStatusInfo is useful for monitoring the user's state in real-time, helping to detect signs of drowsiness and measure attention levels during interactions.
Variables | type | description |
---|---|---|
isDrowsy | bool | A boolean value indicating whether the user is detected as drowsy. |
drowsinessIntensity | double | A double value (0.0 to 1.0) representing the intensity of drowsiness, where 0.0 indicates no drowsiness and 1.0 indicates extreme drowsiness. |
attentionScore | double | A double value (0.0 to 1.0) representing the user's attention level, where 0.0 means no attention and 1.0 means full attention. |
StatusInfo
class StatusInfo {
late final StatusType type;
late final StatusErrorType? errorType;
}
A class that represents the status information for Eyedid SDK's GazeTracker status event. It contains the status type (e.g., start, stop, unknown) and an optional error type if any error occurs when stopping.
Variables | type | description |
---|---|---|
type | StatusType | The type of status event, such as 'start', 'stop', or 'unknown'. |
errorType | StatusErrorType | The type of error that occurred when the status is 'stop'. Can be null if no error occurs or if the status is not 'stop'. |
Example
_eyedidFlutterPlugin.getStatusEvent().listen((event) {
final info = StatusInfo(event);
if (info.type == StatusType.start) {
setState(() {
_stateString = "start Tracking";
_showingGaze = true;
});
} else {
setState(() {
_stateString = "stop Trakcing : ${info.errorType?.name}";
_showingGaze = false;
});
}
});
CalibrationInfo
class CalibrationInfo {
late final CalibrationType type;
late final double? progress;
late final Point<double>? next;
late final List<double>? data;
}
A class that represents calibration status information for the Eyedid SDK. It contains the type of calibration event, progress percentage, the next calibration point, and calibration data if available.
Variables | type | description |
---|---|---|
type | CalibrationType | The type of calibration event: progress, nextPoint, finished, or unknown. |
progress | double? | The progress of the calibration process (0.0 to 1.0). Can be null if not applicable. |
next | Point<double> | The next point for calibration. This is used when the event indicates the next calibration point. Can be null if not applicable. |
data | List<double>? | Calibration data collected when the calibration is finished. Can be null if not applicable. |
Example
_eyedidFlutterPlugin.getCalibrationEvent().listen((event) {
final info = CalibrationInfo(event);
if (info.type == CalibrationType.nextPoint) {
setState(() {
_nextX = info.next!.x;
_nextY = info.next!.y;
_calibrationProgress = 0.0;
});
Future.delayed(const Duration(milliseconds: 500), () {
_eyedidFlutterPlugin.startCollectSamples();
});
} else if (info.type == CalibrationType.progress) {
setState(() {
_calibrationProgress = info.progress!;
});
} else if (info.type == CalibrationType.finished) {
setState(() {
_isCaliMode = false;
});
}
});
OneEuroFilterManager
class OneEuroFilterManager {
static const double _defaultFrequency = 30.0;
static const double _defaultMinCutOFF = 1.0;
static const double _defaultBeta = 0.007;
static const double _defaultDCutOFF = 1.0;
}
Manages a collection of OneEuroFilters for filtering multiple values.
Summary
Function | Description |
---|---|
Constructor | OneEuroFilterManager constructor. |
filterValues | Performs filtering for the given timestamp and a list of values. |
getFilteredValues | Retrieves the filtered values obtained after applying the filter. |
Constructor
OneEuroFilterManager(
{required int count,
freq = _defaultFrequency,
minCutOff = _defaultMinCutOFF,
beta = _defaultBeta,
dCutOff = _defaultDCutOFF})
Use this constructor to initialize the filter and specify the number of values to filter and the filter's settings.
Parameters | Type | Description |
---|---|---|
count | int | The number of values to filter. For example, if set to 2, it filters two input values separately. |
freq | double | Represents the sampling frequency of the data. The default value is 30.0 |
minCutOff | double | Minimum cutoff frequency used to filter noise in the data. The default value is 1.0 |
beta | double | Indicates the strength of applying the derivative filter. The default value is 0.007 |
dCutOff | double | Represents the cutoff frequency for the derivative data. The default value is 1.0 |
Example
he method uses default values for freq, minCutOff, beta, and dCutOff.
OneEuroFilterManager _filterManager = OneEuroFilterManager(count: 2);
filterValues
bool filterValues(int timestamp, List<double> val)
Performs filtering for the given timestamp and a list of values.
Use this method to perform filtering on the given data and obtain the filtered results. If filtering fails or if there are invalid values, the filter is reset, and false is returned.
Parameters | Type | Description |
---|---|---|
timestamp | int | Represents the timestamp of the data and is used for filtering. |
val | List<double> | A list of values to be filtered, representing the values for which you want to obtain filtered results. |
Return Type | Description |
---|---|
bool | If a value is invalid or anomalous, the filter is reset, and false is returned. If the filtering is successful, it returns true. |
Example
final metricsInfo = MetricsInfo(event);
this.gazeInfo = metricsInfo.gazeInfo;
if (_useFilter) {
bool isFiltered = _filterManager
.filterValues(metricsInfo.timestamp, [gazeInfo.gaze.x, gazeInfo.gaze.y]);
if (isFiltered) {
print("filtered success!");
}
}
getFilteredValues
List<double> getFilteredValues()
Retrieves the filtered values obtained after applying the filter.
This function returns a list of filtered double values that have been processed using the filter. It allows you to access the filtered results for further use.
Return Type | Description |
---|---|
List<double> | A list of filtered double values. |
Example
bool isFiltered = _filterManager
.filterValues(metricsInfo.timestamp, [gazeInfo.gaze.x, gazeInfo.gaze.y]);
if (isFiltered) {
List<Double> filtered = _filterManager.getFilteredValues();
print("filtered (x ,y) : (${filtered[0]}, ${filtered[1]})");
}
CalibrationMode
enum CalibrationMode { one, five }
Defines the calibration modes for the Eyedid SDK.
one
: Calibration with a single target point.five
: Calibration with five target points for greater accuracy.
CalibrationCriteria
enum CalibrationCriteria { low, standard, high }
Represents different calibration criteria levels.
low
: Low accuracy, faster calibration.standard
: Default level for general use.high
: High accuracy for precise calibration.
TrackingState
enum TrackingState { success, gazeNotFound, faceMissing }
TrackingState represents the different states that the tracking system can be in during gaze and face tracking.
success
: The tracking is successful, and the gaze is detected correctly.gazeNotFound
: The tracking system is active, but the gaze could not be detected.faceMissing
: The tracking system cannot detect the face, making gaze tracking impossible.
EyemovementState
enum EyemovementState { fixation, saccade, unknown }
EyemovementState represents the different states of eye movement detected by the tracking system.
fixation
: The eye is fixated on a specific point, indicating stable gaze.saccade
: A rapid movement of the eye between fixation points, indicating quick gaze shifts.unknown
: The state of the eye movement is undetermined or not recognized.
ScreenState
enum ScreenState { insideOfScreen, outsideOfScreen, unknown }
ScreenState represents the different states of the user's gaze in relation to the screen boundaries.
insideOfScreen
: The user's gaze is detected within the screen boundaries.outsideOfScreen
: The user's gaze is detected outside of the screen boundaries.unknown
: The state of the user's gaze in relation to the screen cannot be determined.
StatusType
enum StatusType { start, stop, unknown }
Enum representing the different types of status events.
StatusErrorType
enum StatusErrorType {
none,
cameraStart,
cameraInterrupt,
unknown,
}
Enum representing the different types of errors that can occur when the status is 'stop'.
none
: No error occurred.cameraStart
: Error when starting the camera.cameraInterrupt
: Error due to camera interruption.unknown
: An unknown error occurred.
CalibrationType
enum CalibrationType {
progress,
nextPoint,
finished,
unknown
}
Enum representing the different types of calibration events.
progress
: Calibration is in progress.nextPoint
: Next calibration point is available.finished
: Calibration has finished and data is available.unknown
: Unknown calibration type.
EyedidDeviceOrientation
enum EyedidDeviceOrientation {
portrait,
portraitUpsideDown,
landscapeLeft,
landscapeRight,
}
Represents different gaze event orientations for tracking in the Eyedid SDK on iOS. Used to adjust the direction of gaze coordinates based on the device orientation.
portrait
: Device is in portrait mode, Home button at the bottom.portraitUpsideDown
: Device is in portrait mode, Home button at the top.landscapeLeft
: Device is in landscape mode, Home button on the left.landscapeRight
: Device is in landscape mode, Home button on the right.