MagicLeapPixelSensorFeature
NameSpace: PixelSensors
Enables the Magic Leap OpenXR Loader for Android, and modifies the AndroidManifest to be compatible with ML2.
Inherits from: 
MagicLeapOpenXRFeatureWithInterception< MagicLeapPixelSensorFeature >,
MagicLeapOpenXRFeatureBase,
OpenXRFeature
Public Fields
RequiredCapabilities
public HashSet< PixelSensorCapabilityType > RequiredCapabilities { get; set; }
| Type | Description | 
|---|---|
| HashSet< PixelSensorCapabilityType > | The configurable capability types of a pixel sensor | 
Public Methods
void ApplySensorConfig
Apply a configuration to a sensor
public void ApplySensorConfig(
    PixelSensorId sensorType,
    PixelSensorConfigData configData
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| PixelSensorConfigData | configData | The config data to apply | 
Details*
To configure a sensor, capabilities have to be configured iteratively
Each applied configuration can impact other capabilities.
So, when applying a sensor config, query for the other capabilities that have not been applied to get the updated range and to check if this applied config can configure the sensor
Note: Every subsequent application of the same capability for the same stream will overwrite the previous value
void ApplySensorConfig
An overloaded ApplySensorConfig that applies a float value for a capability
public void ApplySensorConfig(
    PixelSensorId sensorType,
    PixelSensorCapabilityType capabilityType,
    float value,
    uint streamIndex
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| PixelSensorCapabilityType | capabilityType | The capability type | 
| float | value | The float value to be applied | 
| uint | streamIndex | The stream index | 
void ApplySensorConfig
An overloaded ApplySensorConfig that applies a bool value for a capability
public void ApplySensorConfig(
    PixelSensorId sensorType,
    PixelSensorCapabilityType capabilityType,
    bool value,
    uint streamIndex
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| PixelSensorCapabilityType | capabilityType | The capability type | 
| bool | value | The bool value to be applied | 
| uint | streamIndex | The stream index | 
void ApplySensorConfig
An overloaded ApplySensorConfig that applies a unsigned int value for a capability
public void ApplySensorConfig(
    PixelSensorId sensorType,
    PixelSensorCapabilityType capabilityType,
    uint value,
    uint streamIndex
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| PixelSensorCapabilityType | capabilityType | The capability type | 
| uint | value | The unsigned int value to be applied | 
| uint | streamIndex | The stream index | 
void ApplySensorConfig
An overloaded ApplySensorConfig that applies a Vector2Int value for a capability
public void ApplySensorConfig(
    PixelSensorId sensorType,
    PixelSensorCapabilityType capabilityType,
    Vector2Int value,
    uint streamIndex
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| PixelSensorCapabilityType | capabilityType | The capability type | 
| Vector2Int | value | The Vector2Int value to be applied | 
| uint | streamIndex | The stream index | 
void ClearAllAppliedConfigs
Clears all the applied configs for a sensor
public void ClearAllAppliedConfigs(
    PixelSensorId sensorType
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
void ClearSensorConfig
Clears an applied config for a capability
public void ClearSensorConfig(
    PixelSensorId sensorType,
    PixelSensorCapabilityType capabilityType,
    uint streamIndex
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| PixelSensorCapabilityType | capabilityType | The capability type | 
| uint | streamIndex | The stream index of the capability | 
PixelSensorAsyncOperationResult ConfigureSensor
Configure a given sensor for the passed streams
public PixelSensorAsyncOperationResult ConfigureSensor(
    PixelSensorId sensorType,
    IEnumerable< uint > streams
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor to configure | 
| IEnumerable< uint > | streams | The streams to configure | 
Returns: An awaitable operation result to indicate the progress of this operation. (See PixelSensorAsyncOperationResult)
PixelSensorAsyncOperationResult ConfigureSensorWithDefaultCapabilities
Configures a sensor with default capabilities
public PixelSensorAsyncOperationResult ConfigureSensorWithDefaultCapabilities(
    PixelSensorId sensorType,
    params uint [] streams
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| params uint [] | streams | The streams to configure | 
Returns: An async operation object for this operation (See: PixelSensorAsyncOperationResult)
bool CreatePixelSensor
Create a pixel sensor of the given type
public bool CreatePixelSensor(
    PixelSensorId sensorType
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor to create | 
Returns: True if the sensor was created
bool DestroyPixelSensor
Destroys a created pixel sensor
public bool DestroyPixelSensor(
    PixelSensorId sensorType
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor to create | 
Returns: True if the sensor was destroyed
bool EnumeratePixelSensorMetaDataTypes
Gets the available metadata types for a sensor's stream.
public bool EnumeratePixelSensorMetaDataTypes(
    PixelSensorId sensorType,
    uint streamIndex,
    out PixelSensorMetaDataType [] metaDataTypes
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| uint | streamIndex | The stream to get the metadata for | 
| out PixelSensorMetaDataType [] | metaDataTypes | The types of the metadata that are supported | 
Details*
Note: A sensor has to be configured in order to be able to get its supported metadata types
Returns: True if the supported metadata types were fetched
bool GetConfiguredValueForSensor
Get a configured value for a sensor.
public bool GetConfiguredValueForSensor(
    PixelSensorId sensorType,
    uint streamIndex,
    PixelSensorCapabilityType capabilityType,
    out PixelSensorConfigData result
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| uint | streamIndex | The stream index to get the configured value for | 
| PixelSensorCapabilityType | capabilityType | The type of the capability | 
| out PixelSensorConfigData | result | The configured value | 
Details*
A configured value is the value that is applied to the sensor by calling ApplySensorConfig(MagicLeap.OpenXR.Features.PixelSensors.MagicLeapPixelSensorFeature.PixelSensorId,MagicLeap.OpenXR.Features.PixelSensors.MagicLeapPixelSensorFeature.PixelSensorConfigData)
Returns: True if a valid configuration was found
bool GetPixelSensorCapabilities
Get all the capabilities that a pixel sensor supports
public bool GetPixelSensorCapabilities(
    PixelSensorId sensorType,
    uint streamIndex,
    out PixelSensorCapability [] capabilities
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the pixel sensor | 
| uint | streamIndex | The stream index for which to get the supported capabilities for | 
| out PixelSensorCapability [] | capabilities | The array of capabilities supported | 
Returns: True if the capabilities were fetched
bool GetPixelSensorFromXrPath
Get a Pixel Sensor given an XrPath String
public bool GetPixelSensorFromXrPath(
    string path,
    out PixelSensorId sensorId
)
Parameters
| Type | Name | Description | 
|---|---|---|
| string | path | The XrPath string of the sensor. /pixelsensor/world/left for example | 
| out PixelSensorId | sensorId | The PixelSensorId associated with the sensor | 
Returns: True if a sensor was found, false otherwise
bool GetSensorData
Get the sensor data of a started sensor
public bool GetSensorData(
    PixelSensorId sensorType,
    uint streamIndex,
    out PixelSensorFrame frame,
    out PixelSensorMetaData [] metaData,
    Allocator allocator,
    long timeOut =10,
    bool shouldFlipTexture =true
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor to get the data for | 
| uint | streamIndex | The stream to get the data for | 
| out PixelSensorFrame | frame | The current frame data of the sensor | 
| out PixelSensorMetaData [] | metaData | The metadata for this frame | 
| Allocator | allocator | An allocator handle that will be used to allocate the memory for the underlying raw data | 
| long | timeOut | The expected timeout for the data fetch | 
| bool | shouldFlipTexture | Whether to fip the obtained texture. The data stored in the sensor could be flipped. Pass in false if the raw data is needed | 
Returns: True if a frame was obtained
Quaternion GetSensorFrameRotation
The sensor data stored can have differing orientations.
public Quaternion GetSensorFrameRotation(
    PixelSensorId sensorType
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor to get the rotation for | 
Returns: The rotation of the frame data
Pose GetSensorPose
Get the sensor pose
public Pose GetSensorPose(
    PixelSensorId sensorType,
    Pose offset =default
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
| Pose | offset | The offset that should be considered for the pose calculation | 
Returns: The pose of the sensor
PixelSensorStatus GetSensorStatus
Get the status of the sensor
public PixelSensorStatus GetSensorStatus(
    PixelSensorId sensorType
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
Returns: The status of the sensor
uint GetStreamCount
Gets the number of streams supported by a sensor
public uint GetStreamCount(
    PixelSensorId sensorType
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor | 
Returns: The number of streams supported by the sensor
List< PixelSensorId > GetSupportedSensors
Get all the supported sensors on the device.
public List< PixelSensorId > GetSupportedSensors()
Details*
Note: This will return all the sensors the device supports, not sensors that are currently available
Returns: List of the supported sensors on the platform
bool IsCapabilityRequired
Returns if a given capability is required to configure a sensor
public bool IsCapabilityRequired(
    PixelSensorCapabilityType capabilityType
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorCapabilityType | capabilityType | The type of capability to check | 
Returns: True if the capability is required for a successful configuration of the sensor
bool QueryPixelSensorCapability
Query a particular capability of a sensor to get its valid range
public bool QueryPixelSensorCapability(
    PixelSensorId sensorType,
    PixelSensorCapabilityType capabilityType,
    uint streamIndex,
    out PixelSensorCapabilityRange capabilityRange
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor to query the capability for | 
| PixelSensorCapabilityType | capabilityType | The type of the capability to query | 
| uint | streamIndex | The stream for which to query the capability | 
| out PixelSensorCapabilityRange | capabilityRange | The range of the capability. Use the return value to determine if this value is accurate or not | 
Returns: True if the query was successful
PixelSensorAsyncOperationResult StartSensor
Start a configured sensor
public PixelSensorAsyncOperationResult StartSensor(
    PixelSensorId sensorType,
    IEnumerable< uint > streams,
    Dictionary< uint, PixelSensorMetaDataType[]> metaDataTypes =null
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor to start | 
| IEnumerable< uint > | streams | The streams to start for the sensor | 
| Dictionary< uint, PixelSensorMetaDataType[]> | metaDataTypes | The types of the metadata for each stream | 
Returns: An awaitable operation result to indicate the progress of this operation. (See PixelSensorAsyncOperationResult)
PixelSensorAsyncOperationResult StopSensor
Stops a given sensor for the passed streams
public PixelSensorAsyncOperationResult StopSensor(
    PixelSensorId sensorType,
    IEnumerable< uint > streams
)
Parameters
| Type | Name | Description | 
|---|---|---|
| PixelSensorId | sensorType | The type of the sensor to stop | 
| IEnumerable< uint > | streams | The streams to stop | 
Returns: An awaitable operation result to indicate the progress of this operation. (See PixelSensorAsyncOperationResult)
Protected Methods
MarkFunctionsToIntercept
protected virtual override void MarkFunctionsToIntercept()
Reimplements: MarkFunctionsToIntercept
OnInstanceCreate
protected override bool OnInstanceCreate(
    ulong xrInstance
)
Parameters
| Type | Name | Description | 
|---|---|---|
| ulong | xrInstance | 
OnInstanceDestroy
protected override void OnInstanceDestroy(
    ulong xrInstance
)
Parameters
| Type | Name | Description | 
|---|---|---|
| ulong | xrInstance | 
Public Attributes
FeatureId
public const string FeatureId = "com.magicleap.openxr.feature.ml2_pixel_sensor";
PixelSensorCapabilityRangeType
Gets the capability range type and the capability data type for a sensor's capability
public PixelSensorCapabilityRangeType;
Parameters
| Type | Name | Description | 
|---|---|---|
| sensorType | The type of the sensor | |
| streamIndex | The stream index to query the capability for | |
| capabilityType | The capability type | 
Returns: The range type and the data type for the capability
Protected Attributes
UsesExperimentalExtensions
protected override bool UsesExperimentalExtensions => true;
Public Events
OnSensorAvailabilityChanged
public Action< PixelSensorId, bool > OnSensorAvailabilityChanged()