Skip to main content
Version: 14 Oct 2024

ml_eye_camera.h

Classes

Name
structMLEyeCameraSettings
A structure to encapsulate the camera settings.
structMLEyeCameraFrameBuffer
A structure to encapsulate per plane info for each camera frame.
structMLEyeCameraFrame
A structure to encapsulate output data for each camera sensor.
structMLEyeCameraData
A structure to encapsulate all the eye camera data.

Types

Name
typedef struct MLEyeCameraSettingsMLEyeCameraSettings
A structure to encapsulate the camera settings.
typedef struct MLEyeCameraFrameBufferMLEyeCameraFrameBuffer
A structure to encapsulate per plane info for each camera frame.
typedef struct MLEyeCameraFrameMLEyeCameraFrame
A structure to encapsulate output data for each camera sensor.
typedef struct MLEyeCameraDataMLEyeCameraData
A structure to encapsulate all the eye camera data.

Enums

Name
enumMLEyeCameraIdentifier
{
MLEyeCameraIdentifier_None = 0,
MLEyeCameraIdentifier_LeftTemple = 1 << 0,
MLEyeCameraIdentifier_LeftNasal = 1 << 1,
MLEyeCameraIdentifier_RightNasal = 1 << 2,
MLEyeCameraIdentifier_RightTemple = 1 << 3,
MLEyeCameraIdentifier_All = MLEyeCameraIdentifier_LeftTemple
MLEyeCameraIdentifier_LeftNasal
MLEyeCameraIdentifier_RightNasal
MLEyeCameraIdentifier_RightTemple,
MLEyeCameraIdentifier_Ensure32Bits = 0x7FFFFFFF
}
Camera Identifier.

Functions

Name
voidMLEyeCameraSettingsInit(MLEyeCameraSettings * inout_settings)
Initialize the camera settings structure. Shall be called before calling MLEyeCameraConnect().
voidMLEyeCameraDataInit(MLEyeCameraData * inout_eye_camera_data)
Initialize MLEyeCameraData with version.
MLResultMLEyeCameraConnect(const MLEyeCameraSettings settings, MLHandle out_handle)
Connect to eye cameras.
MLResultMLEyeCameraUpdateSettings(MLHandle handle, const MLEyeCameraSettings * settings)
Update the eye camera settings.
MLResultMLEyeCameraGetLatestCameraData(MLHandle handle, uint64_t timeout_ms, MLEyeCameraData * out_data)
Poll for Frames.
MLResultMLEyeCameraReleaseCameraData(MLHandle handle, MLEyeCameraData * eye_camera_data)
Releases specified MLEyeCameraData object.
MLResultMLEyeCameraDisconnect(MLHandle handle)
Disconnect from eye camera(s).

Enums Documentation

MLEyeCameraIdentifier

EnumeratorValueDescription
MLEyeCameraIdentifier_None0None.
MLEyeCameraIdentifier_LeftTemple1 << 0Left temple eye camera.
MLEyeCameraIdentifier_LeftNasal1 << 1Left nasal eye camera.
MLEyeCameraIdentifier_RightNasal1 << 2Right nasal eye camera.
MLEyeCameraIdentifier_RightTemple1 << 3Right temple eye camera.
MLEyeCameraIdentifier_AllMLEyeCameraIdentifier_LeftTemple
MLEyeCameraIdentifier_LeftNasal
MLEyeCameraIdentifier_RightNasal
MLEyeCameraIdentifier_RightTempleAll Eye cameras.
MLEyeCameraIdentifier_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Camera Identifier.

Enumeration of all the available eye camera sensors.


Types Documentation

MLEyeCameraSettings

typedef struct MLEyeCameraSettings MLEyeCameraSettings;

A structure to encapsulate the camera settings.

This structure must be initialized by calling MLEyeCameraSettingsInit before use.

More Info

API Level:

  • 26

MLEyeCameraFrameBuffer

typedef struct MLEyeCameraFrameBuffer MLEyeCameraFrameBuffer;

A structure to encapsulate per plane info for each camera frame.

More Info

API Level:

  • 26

MLEyeCameraFrame

typedef struct MLEyeCameraFrame MLEyeCameraFrame;

A structure to encapsulate output data for each camera sensor.

More Info

API Level:

  • 26

MLEyeCameraData

typedef struct MLEyeCameraData MLEyeCameraData;

A structure to encapsulate all the eye camera data.

This structure must be initialized by calling MLEyeCameraDataInit before use.

More Info

API Level:

  • 26

Functions Documentation

MLEyeCameraSettingsInit

static inline void MLEyeCameraSettingsInit(
MLEyeCameraSettings * inout_settings
)

Initialize the camera settings structure. Shall be called before calling MLEyeCameraConnect().

Parameters

MLEyeCameraSettings *inout_settingsMLEyeCameraSettings structure to initialize.

Required Permissions:

  • None

API Level:

  • 26

MLEyeCameraDataInit

static inline void MLEyeCameraDataInit(
MLEyeCameraData * inout_eye_camera_data
)

Initialize MLEyeCameraData with version.

Parameters

MLEyeCameraData *inout_eye_camera_dataSet up the version for inout_eye_camera_data.

API Level:

  • 26

MLEyeCameraConnect

MLResult MLEyeCameraConnect(
const MLEyeCameraSettings * settings,
MLHandle * out_handle
)

Connect to eye cameras.

Parameters

const MLEyeCameraSettings *settingsA pointer to MLEyeCameraSettings structure.
MLHandle *out_handleA pointer to camera handle to be used in later APIs.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkConnected to camera device(s) successfully.
MLResultMLResult_PermissionDeniedNecessary permission is missing.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.

Required Permissions:

  • com.magicleap.permission.EYE_CAMERA (protection level: dangerous)

API Level:

  • 26

MLEyeCameraUpdateSettings

MLResult MLEyeCameraUpdateSettings(
MLHandle handle,
const MLEyeCameraSettings * settings
)

Update the eye camera settings.

Parameters

MLHandlehandleCamera handle obtained from MLEyeCameraConnect.
const MLEyeCameraSettings *settingsPointer to MLEyeCameraSettings.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkSettings updated successfully.
MLResultMLResult_UnspecifiedFailureFailed due to internal error.

Required Permissions:

  • None

API Level:

  • 26

MLEyeCameraGetLatestCameraData

MLResult MLEyeCameraGetLatestCameraData(
MLHandle handle,
uint64_t timeout_ms,
MLEyeCameraData * out_data
)

Poll for Frames.

Parameters

MLHandlehandleCamera handle obtained from MLEyeCameraConnect.
uint64_ttimeout_msTimeout in milliseconds.
MLEyeCameraData *out_dataEye camera data. Will be set to NULL if no valid data is available at this time.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkCamera frames fetched successfully.
MLResultMLResult_TimeoutReturned because no new frame available at this time.
MLResultMLResult_UnspecifiedFailureFailed due to internal error.

Required Permissions:

  • None

Returns MLEyeCameraData with this latest data when available. The memory is owned by the system. Application should copy the data it needs to cache and release the memory by calling MLEyeCameraReleaseCameraData.

This is a blocking call. API is not thread safe.

If there are no new camera frames within the timeout_ms duration then the API will return MLResult_Timeout.

API Level:

  • 26

MLEyeCameraReleaseCameraData

MLResult MLEyeCameraReleaseCameraData(
MLHandle handle,
MLEyeCameraData * eye_camera_data
)

Releases specified MLEyeCameraData object.

Parameters

MLHandlehandleCamera handle obtained from MLEyeCameraConnect.
MLEyeCameraData *eye_camera_dataPointer to a valid MLEyeCameraData object.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkSuccessfully released eye camera data.
MLResultMLResult_UnspecifiedFailureFailed due to internal error.

Required Permissions:

  • None

This function should be called exactly once for each call to MLEyeCameraGetLatestCameraData.

API Level:

  • 26

MLEyeCameraDisconnect

MLResult MLEyeCameraDisconnect(
MLHandle handle
)

Disconnect from eye camera(s).

Parameters

MLHandlehandleCamera handle obtained from MLEyeCameraConnect.

Returns

MLResultMLResult_InvalidParamInvalid handle.
MLResultMLResult_OkDisconnected camera(s) successfully.
MLResultMLResult_UnspecifiedFailureFailed to disconnect camera(s).

Required Permissions:

  • None

This will disconnect from all the eye camera(s) currently connected.

API Level:

  • 26

Source code

// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2022 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 MLEyeCameraIdentifier{
MLEyeCameraIdentifier_None = 0,
MLEyeCameraIdentifier_LeftTemple = 1 << 0,
MLEyeCameraIdentifier_LeftNasal = 1 << 1,
MLEyeCameraIdentifier_RightNasal = 1 << 2,
MLEyeCameraIdentifier_RightTemple = 1 << 3,
MLEyeCameraIdentifier_All = MLEyeCameraIdentifier_LeftTemple |
MLEyeCameraIdentifier_LeftNasal |
MLEyeCameraIdentifier_RightNasal |
MLEyeCameraIdentifier_RightTemple,
MLEyeCameraIdentifier_Ensure32Bits = 0x7FFFFFFF
} MLEyeCameraIdentifier;

typedef struct MLEyeCameraSettings {
uint32_t version;
uint32_t cameras;
} MLEyeCameraSettings;

ML_STATIC_INLINE void MLEyeCameraSettingsInit(MLEyeCameraSettings *inout_settings) {
if (inout_settings) {
memset(inout_settings, 0, sizeof(MLEyeCameraSettings));
inout_settings->version = 1;
inout_settings->cameras = MLEyeCameraIdentifier_All;
}
}

typedef struct MLEyeCameraFrameBuffer {
uint32_t width;
uint32_t height;
uint32_t stride;
uint32_t bytes_per_pixel;
uint32_t pixel_stride;
uint32_t size;
uint8_t *data;
} MLEyeCameraFrameBuffer;

typedef struct MLEyeCameraFrame {
MLEyeCameraIdentifier camera_id;
int64_t frame_number;
MLTime timestamp;
MLEyeCameraFrameBuffer frame_buffer;
} MLEyeCameraFrame;

typedef struct MLEyeCameraData {
uint32_t version;
uint8_t frame_count;
MLEyeCameraFrame *frames;
} MLEyeCameraData;

ML_STATIC_INLINE void MLEyeCameraDataInit(MLEyeCameraData *inout_eye_camera_data) {
if (inout_eye_camera_data) {
memset(inout_eye_camera_data, 0, sizeof(MLEyeCameraData));
inout_eye_camera_data->version = 1;
}
}

ML_API MLResult ML_CALL MLEyeCameraConnect(const MLEyeCameraSettings *settings, MLHandle *out_handle);


ML_API MLResult ML_CALL MLEyeCameraUpdateSettings(MLHandle handle, const MLEyeCameraSettings *settings);

ML_API MLResult ML_CALL MLEyeCameraGetLatestCameraData(MLHandle handle, uint64_t timeout_ms, MLEyeCameraData *out_data);

ML_API MLResult ML_CALL MLEyeCameraReleaseCameraData(MLHandle handle, MLEyeCameraData *eye_camera_data);

ML_API MLResult ML_CALL MLEyeCameraDisconnect(MLHandle handle);

ML_EXTERN_C_END