Struct XRCameraFrame
Represents a frame captured by the device camera with included metadata.
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Syntax
public struct XRCameraFrame : IEquatable<XRCameraFrame>
Constructors
XRCameraFrame(Int64, Single, Single, Color, Matrix4x4, Matrix4x4, TrackingState, IntPtr, XRCameraFrameProperties, Single, Double, Single, Single, Color, Vector3, SphericalHarmonicsL2, XRTextureDescriptor, Single)
Creates a XRCameraFrame.
Declaration
public XRCameraFrame(long timestamp, float averageBrightness, float averageColorTemperature, Color colorCorrection, Matrix4x4 projectionMatrix, Matrix4x4 displayMatrix, TrackingState trackingState, IntPtr nativePtr, XRCameraFrameProperties properties, float averageIntensityInLumens, double exposureDuration, float exposureOffset, float mainLightIntensityInLumens, Color mainLightColor, Vector3 mainLightDirection, SphericalHarmonicsL2 ambientSphericalHarmonics, XRTextureDescriptor cameraGrain, float noiseIntensity)
Parameters
Type | Name | Description |
---|---|---|
Int64 | timestamp | The timestamp of the frame, in nanoseconds. |
Single | averageBrightness | The estimated intensity of the frame, in gamma color space. |
Single | averageColorTemperature | The estimated color temperature of the frame. |
UnityEngine.Color | colorCorrection | The estimated color correction value of the frame. |
UnityEngine.Matrix4x4 | projectionMatrix | The 4x4 projection matrix for the frame. |
UnityEngine.Matrix4x4 | displayMatrix | The 4x4 display matrix for the frame. |
TrackingState | trackingState | The camera's TrackingState when the frame was captured. |
IntPtr | nativePtr | The native pointer associated with the frame. |
XRCameraFrameProperties | properties | The set of flags that indicates which properties are included in the frame.. |
Single | averageIntensityInLumens | The estimated intensity of the real-world environment, in lumens. |
Double | exposureDuration | The camera exposure duration of the frame, in seconds with sub-millisecond precision. |
Single | exposureOffset | The camera exposure offset of the frame for lighting scaling. |
Single | mainLightIntensityInLumens | The estimated intensity in lumens of strongest real-world directional light source. |
UnityEngine.Color | mainLightColor | The estimated color of the strongest real-world directional light source. |
UnityEngine.Vector3 | mainLightDirection | The estimated direction of the strongest real-world directional light source. |
UnityEngine.Rendering.SphericalHarmonicsL2 | ambientSphericalHarmonics | The ambient spherical harmonic coefficients that represent the real-world lighting. |
XRTextureDescriptor | cameraGrain | A texture that simulates the camera's noise. |
Single | noiseIntensity | The level of intensity of camera grain noise in a scene. |
Properties
ambientSphericalHarmonics
The ambient spherical harmonic coefficients that represent the real-world lighting.
Declaration
public readonly SphericalHarmonicsL2 ambientSphericalHarmonics { get; }
Property Value
Type | Description |
---|---|
UnityEngine.Rendering.SphericalHarmonicsL2 | The ambient spherical harmonic coefficients. |
Remarks
See Rendering.SphericalHarmonicsL2 for further details.
averageBrightness
The average pixel intensity of the frame in gamma color space, used to match the intensity of light in the real-world environment. Values are in the range [0.0, 1.0] with zero being black and one being white.
Declaration
public readonly float averageBrightness { get; }
Property Value
Type | Description |
---|---|
Single | The average pixel intensity of the frame. |
See Also
averageColorTemperature
The estimated color temperature of ambient light in the frame, in degrees Kelvin.
Declaration
public readonly float averageColorTemperature { get; }
Property Value
Type | Description |
---|---|
Single | The estimated color temperature. |
Remarks
A value of 6500 represents neutral (pure white) lighting; lower values indicate a "warmer" yellow or orange tint, and higher values indicate a "cooler" blue tint.
averageIntensityInLumens
The estimated intensity of the real-world environment, in lumens. Represents an average of directional light sources.
Declaration
public readonly float averageIntensityInLumens { get; }
Property Value
Type | Description |
---|---|
Single | The estimated intensity. |
See Also
cameraGrain
A texture that simulates the camera's noise.
Declaration
public readonly XRTextureDescriptor cameraGrain { get; }
Property Value
Type | Description |
---|---|
XRTextureDescriptor | The camera grain texture. |
colorCorrection
The estimated color correction value of the frame.
Declaration
public readonly Color colorCorrection { get; }
Property Value
Type | Description |
---|---|
UnityEngine.Color | The color correction value. |
Remarks
The RGB scale factors are not intended to brighten nor dim the scene. They are only to shift the color of virtual objects towards the color of the light; not intensity of the light.
displayMatrix
The 4x4 display matrix for the frame. Defines how to render the frame to the screen.
Declaration
public readonly Matrix4x4 displayMatrix { get; }
Property Value
Type | Description |
---|---|
UnityEngine.Matrix4x4 | The display matrix. |
exposureDuration
The camera exposure duration of the frame, in seconds with sub-millisecond precision.
Declaration
public readonly double exposureDuration { get; }
Property Value
Type | Description |
---|---|
Double | The camera exposure duration. |
exposureOffset
The camera exposure offset of the frame for lighting scaling.
Declaration
public readonly float exposureOffset { get; }
Property Value
Type | Description |
---|---|
Single | The camera exposure offset. |
hasAmbientSphericalHarmonics
Indicates whether ambientSphericalHarmonics was assigned a value.
Declaration
public readonly bool hasAmbientSphericalHarmonics { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has values for ambient spherical harmonics coefficients. Otherwise, false. |
hasAverageBrightness
Indicates whether averageBrightness was assigned a value.
Declaration
public readonly bool hasAverageBrightness { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has an average brightness value. Otherwise, false. |
hasAverageColorTemperature
Indicates whether averageColorTemperature was assigned a value.
Declaration
public readonly bool hasAverageColorTemperature { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has an average color temperature value. Otherwise, false. |
hasAverageIntensityInLumens
Indicates whether averageIntensityInLumens was assigned a value.
Declaration
public readonly bool hasAverageIntensityInLumens { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has an average intensity value in lumens. Otherwise, false. |
hasCameraGrain
Indicates whether cameraGrain was assigned a value.
Declaration
public readonly bool hasCameraGrain { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has a camera grain texture. Otherwise, false. |
hasColorCorrection
Indicates whether colorCorrection was assigned a value.
Declaration
public readonly bool hasColorCorrection { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has a color correction value. Otherwise, false. |
hasDisplayMatrix
Indicates whether displayMatrix was assigned a value.
Declaration
public readonly bool hasDisplayMatrix { get; }
Property Value
Type | Description |
---|---|
Boolean |
hasExposureDuration
Indicates whether exposureDuration was assigned a value.
Declaration
public readonly bool hasExposureDuration { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has an exposure duration value. Otherwise, false. |
hasExposureOffset
Indicates whether exposureOffset was assigned a value.
Declaration
public readonly bool hasExposureOffset { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has an exposure offset value. Otherwise, false. |
hasMainLightColor
Indicates whether mainLightColor was assigned a value.
Declaration
public readonly bool hasMainLightColor { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has an estimated main light color value. Otherwise, false. |
hasMainLightDirection
Indicates whether mainLightDirection was assigned a value.
Declaration
public readonly bool hasMainLightDirection { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has an estimated main light direction value. Otherwise, false. |
hasMainLightIntensityLumens
Indicates whether mainLightIntensityLumens was assigned a value.
Declaration
public readonly bool hasMainLightIntensityLumens { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has an estimated main light intensity value. Otherwise, false. |
hasNoiseIntensity
Indicates whether noiseIntensity was assigned a value.
Declaration
public readonly bool hasNoiseIntensity { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has a camera grain noise intensity value. Otherwise, false. |
hasProjectionMatrix
Indicates whether projectionMatrix was assigned a value.
Declaration
public readonly bool hasProjectionMatrix { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the frame has a projection matrix. Otherwise, false. |
hasTimestamp
Indicates whether timestampNs was assigned a value.
Declaration
public readonly bool hasTimestamp { get; }
Property Value
Type | Description |
---|---|
Boolean |
mainLightColor
The estimated color of the strongest directional light source in the real-world environment.
Declaration
public readonly Color mainLightColor { get; }
Property Value
Type | Description |
---|---|
UnityEngine.Color | The estimated color of the main light. |
mainLightDirection
The estimated direction of the strongest directional light source in the real-world environment.
Declaration
public readonly Vector3 mainLightDirection { get; }
Property Value
Type | Description |
---|---|
UnityEngine.Vector3 | The estimated direction of the main light. |
mainLightIntensityLumens
The estimated intensity in lumens of the strongest directional light source in the real-world environment.
Declaration
public readonly float mainLightIntensityLumens { get; }
Property Value
Type | Description |
---|---|
Single | The estimated intensity of the main light. |
nativePtr
The native pointer associated with this frame. The data pointed to by this pointer is specific to provider implementation.
Declaration
public readonly IntPtr nativePtr { get; }
Property Value
Type | Description |
---|---|
IntPtr | The native pointer. |
noiseIntensity
The level of intensity of camera grain noise in a scene.
Declaration
public readonly float noiseIntensity { get; }
Property Value
Type | Description |
---|---|
Single | The noise intensity. |
projectionMatrix
The 4x4 projection matrix for the frame.
Declaration
public readonly Matrix4x4 projectionMatrix { get; }
Property Value
Type | Description |
---|---|
UnityEngine.Matrix4x4 | The projection matrix. |
properties
The set of flags that indicates which properties are included in the frame.
Declaration
public readonly XRCameraFrameProperties properties { get; }
Property Value
Type | Description |
---|---|
XRCameraFrameProperties | The included camera frame properties. |
timestampNs
The timestamp of the frame, in nanoseconds.
Declaration
public readonly long timestampNs { get; }
Property Value
Type | Description |
---|---|
Int64 | The timestamp. |
trackingState
The camera's TrackingState when this frame was captured.
Declaration
public readonly TrackingState trackingState { get; }
Property Value
Type | Description |
---|---|
TrackingState | The tracking state. |
Methods
Equals(Object)
Compares for equality.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | An |
Returns
Type | Description |
---|---|
Boolean | true if |
Overrides
Equals(XRCameraFrame)
Compares for equality.
Declaration
public bool Equals(XRCameraFrame other)
Parameters
Type | Name | Description |
---|---|---|
XRCameraFrame | other | The other XRCameraFrame to compare against. |
Returns
Type | Description |
---|---|
Boolean | true if the XRCameraFrame represents the same object. Otherwise, false. |
Implements
GetHashCode()
Generates a hash code suitable for use in HashSet
and Dictionary
.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash of this XRCameraFrame. |
Overrides
ToString()
Generates a string representation of this XRCameraFrame suitable for debugging purposes.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string representation of this XRCameraFrame. |
Overrides
TryGetAverageBrightness(out Single)
Get the average brightness of the frame if possible.
Declaration
public bool TryGetAverageBrightness(out float averageBrightness)
Parameters
Type | Name | Description |
---|---|---|
Single | averageBrightness | The average pixel intensity of the frame, equal to averageBrightness. |
Returns
Type | Description |
---|---|
Boolean | true if the frame has an average brightness value. Otherwise, false. Equal to hasAverageBrightness. |
TryGetAverageColorTemperature(out Single)
Get the estimated color temperature of the frame if possible.
Declaration
public bool TryGetAverageColorTemperature(out float averageColorTemperature)
Parameters
Type | Name | Description |
---|---|---|
Single | averageColorTemperature | The estimated color temperature of the frame, in degrees Kelvin. Equal to averageColorTemperature. |
Returns
Type | Description |
---|---|
Boolean | true if the frame has an estimated color temperature value. Otherwise, false. Equal to hasAverageColorTemperature. |
TryGetAverageIntensityInLumens(out Single)
Get the estimated intensity in lumens of the real-world environment, if possible.
Declaration
public bool TryGetAverageIntensityInLumens(out float averageIntensityInLumens)
Parameters
Type | Name | Description |
---|---|---|
Single | averageIntensityInLumens | The estimated intensity. Equal to averageIntensityInLumens. |
Returns
Type | Description |
---|---|
Boolean | true if the frame has an estimated intensity value in lumens. Otherwise, returns false. Equal to hasAverageIntensityInLumens. |
TryGetDisplayMatrix(out Matrix4x4)
Get the display matrix for the frame if possible.
Declaration
public bool TryGetDisplayMatrix(out Matrix4x4 displayMatrix)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Matrix4x4 | displayMatrix | The display matrix. Equal to displayMatrix. |
Returns
Type | Description |
---|---|
Boolean | true if the frame has a display matrix. Otherwise, false. Equal to hasDisplayMatrix. |
TryGetProjectionMatrix(out Matrix4x4)
Get the projection matrix for the frame if possible.
Declaration
public bool TryGetProjectionMatrix(out Matrix4x4 projectionMatrix)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Matrix4x4 | projectionMatrix | The projection matrix. Equal to projectionMatrix. |
Returns
Type | Description |
---|---|
Boolean | true if the frame has a projection matrix. Otherwise, false. Equal to hasProjectionMatrix. |
TryGetTimestamp(out Int64)
Get the timestamp of the frame if possible.
Declaration
public bool TryGetTimestamp(out long timestampNs)
Parameters
Type | Name | Description |
---|---|---|
Int64 | timestampNs | The timestamp of the camera frame, equal to timestampNs. |
Returns
Type | Description |
---|---|
Boolean | true if the frame has a timestamp. Otherwise, false. Equal to hasTimestamp. |
Operators
Equality(XRCameraFrame, XRCameraFrame)
Compares lhs
and rhs
for equality using Equals(XRCameraFrame).
Declaration
public static bool operator ==(XRCameraFrame lhs, XRCameraFrame rhs)
Parameters
Type | Name | Description |
---|---|---|
XRCameraFrame | lhs | The left-hand-side XRCameraFrame of the comparison. |
XRCameraFrame | rhs | The right-hand-side XRCameraFrame of the comparison. |
Returns
Type | Description |
---|---|
Boolean |
Inequality(XRCameraFrame, XRCameraFrame)
Compares lhs
and rhs
for inequality using Equals(XRCameraFrame).
Declaration
public static bool operator !=(XRCameraFrame lhs, XRCameraFrame rhs)
Parameters
Type | Name | Description |
---|---|---|
XRCameraFrame | lhs | The left-hand-side XRCameraFrame of the comparison. |
XRCameraFrame | rhs | The right-hand-side XRCameraFrame of the comparison. |
Returns
Type | Description |
---|---|
Boolean |