WVR_GetEyeTracking¶
-
WVR_EXPORT WVR_Result WVR_GetEyeTracking(WVR_EyeTracking_t * data, WVR_CoordinateSystem space = WVR_CoordinateSystem_Global)
Function to eye tracking data.
This API is used to get eye tracking data from the eye tracker module This API must be called by main thread.
The tracking data from the eye tracker module itself is on WVR_CoordinateSystem_Local space. If you access API by WVR_CoordinateSystem_Global parameter, you will get tracking data which is transformed to HMD world coordinate space.
- Version
- API Level 9
- Parameters
data
: the eye tracking data WVR_EyeTrackingspace
: the coordinate system of tracking data WVR_CoordinateSystem
- Return Value
WVR_Success
: get data successfully.others
: WVR_Result mean failure.
-
struct
WVR_EyeTracking
¶ The eye tracking data.
-
struct
WVR_CombinedEyeTracking
¶ The combined eye tracking data.
-
struct
WVR_SingleEyeTracking
¶ The single eye tracking data.
Public Members
-
uint64_t
eyeTrackingValidBitMask
¶ The bits containing all validity for this data.
-
WVR_Vector3f_t
gazeOrigin
¶ The point in the eye from which the gaze ray originates in meters.
-
WVR_Vector3f_t
gazeDirectionNormalized
¶ The normalized gaze direction of the eye in [-1,1].
-
float
eyeOpenness
¶ A value representing how open the eye is.
-
float
pupilDiameter
¶ The diameter of pupil in millimeters.
-
WVR_Vector2f_t
pupilPositionInSensorArea
¶ The normalized position of a pupil in [0,1].
-
uint64_t
-
enum
WVR_EyeTrackingStatus
¶ Structure containing flags indicating data validity of an eye pose.
Values:
-
WVR_GazeOriginValid
= 1<<0¶
-
WVR_GazeDirectionNormalizedValid
= 1<<1¶
-
WVR_PupilDiameterValid
= 1<<2¶
-
WVR_EyeOpennessValid
= 1<<3¶
-
WVR_PupilPositionInSensorAreaValid
= 1<<4¶
-
How to use¶
Sample function:
#include <wvr/wvr_eyetracking.h>
#include <wvr/wvr_device.h>
if (WVR_StartEyeTracking() == WVR_Success) {
if(WVR_IsDeviceConnected(WVR_DeviceType::WVR_DeviceType_EyeTracking)) {
WVR_EyeTracking eyeTrackingData;
if (WVR_GetEyeTracking(&eyeTrackingData,
WVR_CoordinateSystem_Global)== WVR_Success) {
// get eye tracking data success
if((eyeTrackingData.left.eyeTrackingValidBitMask & WVR_GazeOriginValid) == WVR_GazeOriginValid)
LOGI("GetEyeTracking left gazeOrigin = (%f,%f,%f)", eyeTrackingData.left.gazeOrigin.v[0],eyeTrackingData.left.gazeOrigin.v[1],eyeTrackingData.left.gazeOrigin.v[2]);
if((eyeTrackingData.right.eyeTrackingValidBitMask & WVR_GazeOriginValid) == WVR_GazeOriginValid)
LOGI("GetEyeTracking right gazeOrigin = (%f,%f,%f)", eyeTrackingData.right.gazeOrigin.v[0],eyeTrackingData.right.gazeOrigin.v[1],eyeTrackingData.right.gazeOrigin.v[2]);
if((eyeTrackingData.combined.eyeTrackingValidBitMask & WVR_GazeOriginValid) == WVR_GazeOriginValid)
LOGI("GetEyeTracking combined gazeOrigin = (%f,%f,%f)", eyeTrackingData.combined.gazeOrigin.v[0],eyeTrackingData.combined.gazeOrigin.v[1],eyeTrackingData.combined.gazeOrigin.v[2]);
if((eyeTrackingData.left.eyeTrackingValidBitMask & WVR_GazeDirectionNormalizedValid) == WVR_GazeDirectionNormalizedValid)
LOGI("GetEyeTracking left gazeDirectionNormalized = (%f,%f,%f)", eyeTrackingData.left.gazeDirectionNormalized.v[0],eyeTrackingData.left.gazeDirectionNormalized.v[1],eyeTrackingData.left.gazeDirectionNormalized.v[2]);
if((eyeTrackingData.right.eyeTrackingValidBitMask & WVR_GazeDirectionNormalizedValid) == WVR_GazeDirectionNormalizedValid)
LOGI("GetEyeTracking right gazeDirectionNormalized = (%f,%f,%f)", eyeTrackingData.right.gazeDirectionNormalized.v[0],eyeTrackingData.right.gazeDirectionNormalized.v[1],eyeTrackingData.right.gazeDirectionNormalized.v[2]);
if((eyeTrackingData.combined.eyeTrackingValidBitMask & WVR_GazeDirectionNormalizedValid) == WVR_GazeDirectionNormalizedValid)
LOGI("GetEyeTracking combined gazeDirectionNormalized = (%f,%f,%f)", eyeTrackingData.combined.gazeDirectionNormalized.v[0],eyeTrackingData.combined.gazeDirectionNormalized.v[1],eyeTrackingData.combined.gazeDirectionNormalized.v[2]);
if((eyeTrackingData.left.eyeTrackingValidBitMask & WVR_PupilDiameterValid) == WVR_PupilDiameterValid)
LOGI("GetEyeTracking left pupilDiameter = %f", eyeTrackingData.left.pupilDiameter);
if((eyeTrackingData.right.eyeTrackingValidBitMask & WVR_PupilDiameterValid) == WVR_PupilDiameterValid)
LOGI("GetEyeTracking right pupilDiameter = %f", eyeTrackingData.right.pupilDiameter);
if((eyeTrackingData.left.eyeTrackingValidBitMask & WVR_EyeOpennessValid) == WVR_EyeOpennessValid)
LOGI("GetEyeTracking left Openness = %f", eyeTrackingData.left.eyeOpenness);
if((eyeTrackingData.right.eyeTrackingValidBitMask & WVR_EyeOpennessValid) == WVR_EyeOpennessValid)
LOGI("GetEyeTracking right Openness = %f", eyeTrackingData.right.eyeOpenness);
if((eyeTrackingData.left.eyeTrackingValidBitMask & WVR_PupilPositionInSensorAreaValid) == WVR_PupilPositionInSensorAreaValid)
LOGI("GetEyeTracking left pupilPositionInSensorArea = (%f,%f)", eyeTrackingData.left.pupilPositionInSensorArea.v[0],eyeTrackingData.left.pupilPositionInSensorArea.v[1]);
if((eyeTrackingData.right.eyeTrackingValidBitMask & WVR_PupilPositionInSensorAreaValid) == WVR_PupilPositionInSensorAreaValid)
LOGI("GetEyeTracking right pupilPositionInSensorArea = (%f,%f)", eyeTrackingData.right.pupilPositionInSensorArea.v[0],eyeTrackingData.right.pupilPositionInSensorArea.v[1]);
LOGI("GetEyeTracking timestamp = %lld", eyeTrackingData.timestamp);
} else {
// get eye tracking failed!
}
}
//WVR_StopEyeTracking
} else {
// start eye tracking failed!
}