ml_eye_tracking.h
Classes
Name | |
---|---|
struct | MLEyeTrackingStaticData Static information about the eye tracking. |
struct | MLEyeTrackingStateEx Information about the state of the eye tracking system. |
Types
Name | |
---|---|
typedef struct MLEyeTrackingStaticData | MLEyeTrackingStaticData Static information about the eye tracking. |
typedef struct MLEyeTrackingStateEx | MLEyeTrackingStateEx Information about the state of the eye tracking system. |
Enums
Name | |
---|---|
enum | MLEyeTrackingError { MLEyeTrackingError_None, MLEyeTrackingError_Generic, MLEyeTrackingError_Ensure32Bits = 0x7FFFFFFF } |
Functions
Name | |
---|---|
void | MLEyeTrackingStateInit(MLEyeTrackingStateEx * inout_state) Initialize MLEyeTrackingStateEx with version. |
MLResult | MLEyeTrackingCreate(MLHandle * out_handle) Creates an eye tracker. |
MLResult | MLEyeTrackingDestroy(MLHandle eye_tracker) Destroys an eye tracker. |
MLResult | MLEyeTrackingGetStaticData(MLHandle eye_tracker, MLEyeTrackingStaticData * out_data) Gets static information about the eye tracker. |
MLResult | MLEyeTrackingGetStateEx(MLHandle eye_tracker, MLEyeTrackingStateEx * out_state) Gets information about the user's eyes. |
Enums Documentation
MLEyeTrackingError
Enumerator | Value | Description |
---|---|---|
MLEyeTrackingError_None | No error, tracking is nominal. | |
MLEyeTrackingError_Generic | Eye Tracker failed. | |
MLEyeTrackingError_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
A set of possible error codes that the Eye Tracking system can report.
Types Documentation
MLEyeTrackingStaticData
typedef struct MLEyeTrackingStaticData MLEyeTrackingStaticData;
Static information about the eye tracking.
Populate with MLEyeTrackingGetStaticData().
API Level:
- 20
MLEyeTrackingStateEx
typedef struct MLEyeTrackingStateEx MLEyeTrackingStateEx;
Information about the state of the eye tracking system.
This structure must be initialized by calling MLEyeTrackingStateInit() before use.
API Level:
- 26
Functions Documentation
MLEyeTrackingStateInit
static inline void MLEyeTrackingStateInit(
MLEyeTrackingStateEx * inout_state
)
Initialize MLEyeTrackingStateEx with version.
Parameters
MLEyeTrackingStateEx * | inout_state | Set up the version for inout_state and zero all other fields. |
API Level:
- 26
MLEyeTrackingCreate
MLResult MLEyeTrackingCreate(
MLHandle * out_handle
)
Creates an eye tracker.
Parameters
MLHandle * | out_handle | A pointer to an MLHandle which will contain the handle of the eye tracker. If this operation fails, out_handle will be ML_INVALID_HANDLE. |
Returns
MLResult | MLResult_InvalidParam | Failed to create eye tracker due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully created eye tracker. |
MLResult | MLResult_UnspecifiedFaiure | Failed to create eye tracker due to an unknown failure. |
MLResult | MLResult_PermissionDenied | The application lacks permission. |
Required Permissions:
- com.magicleap.permission.EYE_TRACKING (protection level: dangerous)
MLEyeTrackingDestroy
MLResult MLEyeTrackingDestroy(
MLHandle eye_tracker
)
Destroys an eye tracker.
Parameters
MLHandle | eye_tracker | A handle to an Eye Tracker created by MLEyeTrackingCreate(). |
Returns
MLResult | MLResult_Ok | Successfully destroyed eye tracker. |
MLResult | MLResult_UnspecifiedFaiure | Failed to destroy eye tracker due to an unknown failure. |
Required Permissions:
- None
MLEyeTrackingGetStaticData
MLResult MLEyeTrackingGetStaticData(
MLHandle eye_tracker,
MLEyeTrackingStaticData * out_data
)
Gets static information about the eye tracker.
Parameters
MLHandle | eye_tracker | A handle to an Eye Tracker created by MLEyeTrackingCreate(). |
MLEyeTrackingStaticData * | out_data | Target to populate the data about the eye tracker. |
Returns
MLResult | MLResult_InvalidParam | The out_data parameter was not valid (null). |
MLResult | MLResult_Ok | Eye tracking static data was successfully received. |
MLResult | MLResult_UnspecifiedFailure | Failed to receive eye tracking static data. |
Required Permissions:
- None
API Level:
- 20
MLEyeTrackingGetStateEx
MLResult MLEyeTrackingGetStateEx(
MLHandle eye_tracker,
MLEyeTrackingStateEx * out_state
)
Gets information about the user's eyes.
Parameters
MLHandle | eye_tracker | A handle to an Eye Tracker created by MLEyeTrackingCreate(). |
MLEyeTrackingStateEx * | out_state | Information about the eyes. |
Returns
MLResult | MLResult_InvalidParam | Failed to receive eye tracking state due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully received eye tracking state. |
MLResult | MLResult_UnspecifiedFailure | Failed to receive eye tracking state due to an unknown failure. |
Required Permissions:
- None
NOTE: To ensure a clean trace of any eye state, it is important to monitor the confidence value of that eye to reject frames where confidence is 0 (or employ another fallback strategy like propagating the last high confidence value).
API Level:
- 9
Source code
// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2017 Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement,
// located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying
// this distribution may also be found in the top-level NOTICE file
// appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%
#pragma once
#include "ml_api.h"
#include "ml_types.h"
#include <string.h>
ML_EXTERN_C_BEGIN
typedef enum MLEyeTrackingError {
MLEyeTrackingError_None,
MLEyeTrackingError_Generic,
MLEyeTrackingError_Ensure32Bits = 0x7FFFFFFF
} MLEyeTrackingError;
typedef struct MLEyeTrackingStaticData {
MLCoordinateFrameUID vergence;
MLCoordinateFrameUID left_center;
MLCoordinateFrameUID right_center;
} MLEyeTrackingStaticData;
typedef struct MLEyeTrackingStateEx {
uint32_t version;
float vergence_confidence;
float left_center_confidence;
float right_center_confidence;
bool left_blink;
bool right_blink;
MLEyeTrackingError error;
MLTime timestamp;
float left_eye_openness;
float right_eye_openness;
} MLEyeTrackingStateEx;
ML_STATIC_INLINE void MLEyeTrackingStateInit(MLEyeTrackingStateEx *inout_state) {
if (inout_state) {
memset(inout_state, 0, sizeof(MLEyeTrackingStateEx));
inout_state->version = 2;
inout_state->error = MLEyeTrackingError_None;
}
}
ML_API MLResult ML_CALL MLEyeTrackingCreate(MLHandle *out_handle);
ML_API MLResult ML_CALL MLEyeTrackingDestroy(MLHandle eye_tracker);
ML_API MLResult ML_CALL MLEyeTrackingGetStaticData(MLHandle eye_tracker, MLEyeTrackingStaticData *out_data);
ML_API MLResult ML_CALL MLEyeTrackingGetStateEx(MLHandle eye_tracker, MLEyeTrackingStateEx *out_state);
ML_EXTERN_C_END