Struct XRCameraFrame
Represents a frame captured by the device camera with included metadata.
Implements
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Assembly: Unity.XR.ARSubsystems.dll
Syntax
public struct XRCameraFrame : IEquatable<XRCameraFrame>
Constructors
XRCameraFrame(long, float, float, Color, Matrix4x4, Matrix4x4, TrackingState, IntPtr, XRCameraFrameProperties, float, double, float, float, Color, Vector3, SphericalHarmonicsL2, XRTextureDescriptor, float)
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 |
---|---|---|
long | timestamp | The timestamp of the frame, in nanoseconds. |
float | averageBrightness | The estimated intensity of the frame, in gamma color space. |
float | averageColorTemperature | The estimated color temperature of the frame. |
Color | colorCorrection | The estimated color correction value of the frame. |
Matrix4x4 | projectionMatrix | The 4x4 projection matrix for the frame. |
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.. |
float | 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. |
float | exposureOffset | The camera exposure offset of the frame for lighting scaling. |
float | mainLightIntensityInLumens | The estimated intensity in lumens of strongest real-world directional light source. |
Color | mainLightColor | The estimated color of the strongest real-world directional light source. |
Vector3 | mainLightDirection | The estimated direction of the strongest real-world directional light source. |
SphericalHarmonicsL2 | ambientSphericalHarmonics | The ambient spherical harmonic coefficients that represent the real-world lighting. |
XRTextureDescriptor | cameraGrain | A texture that simulates the camera's noise. |
float | noiseIntensity | The level of intensity of camera grain noise in a scene. |
XRCameraFrame(long, float, float, Color, Matrix4x4, Matrix4x4, TrackingState, IntPtr, XRCameraFrameProperties, float, double, float, float, Color, Vector3, SphericalHarmonicsL2, XRTextureDescriptor, float, XRCameraFrameExifData)
Creates a XRCameraFrame with EXIF data.
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, XRCameraFrameExifData exifData)
Parameters
Type | Name | Description |
---|---|---|
long | timestamp | The timestamp of the frame, in nanoseconds. |
float | averageBrightness | The estimated intensity of the frame, in gamma color space. |
float | averageColorTemperature | The estimated color temperature of the frame. |
Color | colorCorrection | The estimated color correction value of the frame. |
Matrix4x4 | projectionMatrix | The 4x4 projection matrix for the frame. |
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. |
float | 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. |
float | exposureOffset | The camera exposure offset of the frame for lighting scaling. |
float | mainLightIntensityInLumens | The estimated intensity in lumens of strongest real-world directional light source. |
Color | mainLightColor | The estimated color of the strongest real-world directional light source. |
Vector3 | mainLightDirection | The estimated direction of the strongest real-world directional light source. |
SphericalHarmonicsL2 | ambientSphericalHarmonics | The ambient spherical harmonic coefficients that represent the real-world lighting. |
XRTextureDescriptor | cameraGrain | A texture that simulates the camera's noise. |
float | noiseIntensity | The level of intensity of camera grain noise in a scene. |
XRCameraFrameExifData | exifData | The EXIF data. |
Properties
ambientSphericalHarmonics
The ambient spherical harmonic coefficients that represent the real-world lighting.
Declaration
public SphericalHarmonicsL2 ambientSphericalHarmonics { get; }
Property Value
Type | Description |
---|---|
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 float averageBrightness { get; }
Property Value
Type | Description |
---|---|
float | 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 float averageColorTemperature { get; }
Property Value
Type | Description |
---|---|
float | 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 float averageIntensityInLumens { get; }
Property Value
Type | Description |
---|---|
float | The estimated intensity. |
See Also
cameraGrain
A texture that simulates the camera's noise.
Declaration
public XRTextureDescriptor cameraGrain { get; }
Property Value
Type | Description |
---|---|
XRTextureDescriptor | The camera grain texture. |
colorCorrection
The estimated color correction value of the frame.
Declaration
public Color colorCorrection { get; }
Property Value
Type | Description |
---|---|
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 Matrix4x4 displayMatrix { get; }
Property Value
Type | Description |
---|---|
Matrix4x4 | The display matrix. |
exposureDuration
The camera exposure duration of the frame, in seconds with sub-millisecond precision.
Declaration
public 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 float exposureOffset { get; }
Property Value
Type | Description |
---|---|
float | The camera exposure offset. |
hasAmbientSphericalHarmonics
Indicates whether ambientSphericalHarmonics was assigned a value.
Declaration
public bool hasAmbientSphericalHarmonics { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has values for ambient spherical harmonics coefficients. Otherwise, false. |
hasAverageBrightness
Indicates whether averageBrightness was assigned a value.
Declaration
public bool hasAverageBrightness { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has an average brightness value. Otherwise, false. |
hasAverageColorTemperature
Indicates whether averageColorTemperature was assigned a value.
Declaration
public bool hasAverageColorTemperature { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has an average color temperature value. Otherwise, false. |
hasAverageIntensityInLumens
Indicates whether averageIntensityInLumens was assigned a value.
Declaration
public bool hasAverageIntensityInLumens { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has an average intensity value in lumens. Otherwise, false. |
hasCameraGrain
Indicates whether cameraGrain was assigned a value.
Declaration
public bool hasCameraGrain { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has a camera grain texture. Otherwise, false. |
hasColorCorrection
Indicates whether colorCorrection was assigned a value.
Declaration
public bool hasColorCorrection { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has a color correction value. Otherwise, false. |
hasDisplayMatrix
Indicates whether displayMatrix was assigned a value.
Declaration
public bool hasDisplayMatrix { get; }
Property Value
Type | Description |
---|---|
bool |
hasExposureDuration
Indicates whether exposureDuration was assigned a value.
Declaration
public bool hasExposureDuration { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has an exposure duration value. Otherwise, false. |
hasExposureOffset
Indicates whether exposureOffset was assigned a value.
Declaration
public bool hasExposureOffset { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has an exposure offset value. Otherwise, false. |
hasMainLightColor
Indicates whether mainLightColor was assigned a value.
Declaration
public bool hasMainLightColor { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has an estimated main light color value. Otherwise, false. |
hasMainLightDirection
Indicates whether mainLightDirection was assigned a value.
Declaration
public bool hasMainLightDirection { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has an estimated main light direction value. Otherwise, false. |
hasMainLightIntensityLumens
Indicates whether mainLightIntensityLumens was assigned a value.
Declaration
public bool hasMainLightIntensityLumens { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has an estimated main light intensity value. Otherwise, false. |
hasNoiseIntensity
Indicates whether noiseIntensity was assigned a value.
Declaration
public bool hasNoiseIntensity { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has a camera grain noise intensity value. Otherwise, false. |
hasProjectionMatrix
Indicates whether projectionMatrix was assigned a value.
Declaration
public bool hasProjectionMatrix { get; }
Property Value
Type | Description |
---|---|
bool | true if the frame has a projection matrix. Otherwise, false. |
hasTimestamp
Indicates whether timestampNs was assigned a value.
Declaration
public bool hasTimestamp { get; }
Property Value
Type | Description |
---|---|
bool |
mainLightColor
The estimated color of the strongest directional light source in the real-world environment.
Declaration
public Color mainLightColor { get; }
Property Value
Type | Description |
---|---|
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 Vector3 mainLightDirection { get; }
Property Value
Type | Description |
---|---|
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 float mainLightIntensityLumens { get; }
Property Value
Type | Description |
---|---|
float | 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 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 float noiseIntensity { get; }
Property Value
Type | Description |
---|---|
float | The noise intensity. |
projectionMatrix
The 4x4 projection matrix for the frame.
Declaration
public Matrix4x4 projectionMatrix { get; }
Property Value
Type | Description |
---|---|
Matrix4x4 | The projection matrix. |
properties
The set of flags that indicates which properties are included in the frame.
Declaration
public XRCameraFrameProperties properties { get; }
Property Value
Type | Description |
---|---|
XRCameraFrameProperties | The included camera frame properties. |
timestampNs
The timestamp of the frame, in nanoseconds.
Declaration
public long timestampNs { get; }
Property Value
Type | Description |
---|---|
long | The timestamp. |
trackingState
The camera's TrackingState when this frame was captured.
Declaration
public 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 |
---|---|
bool | 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 |
---|---|
bool | true if the XRCameraFrame represents the same object. Otherwise, false. |
GetHashCode()
Generates a hash code suitable for use in HashSet
and Dictionary
.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | 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 float)
Get the average brightness of the frame if possible.
Declaration
public bool TryGetAverageBrightness(out float averageBrightness)
Parameters
Type | Name | Description |
---|---|---|
float | averageBrightness | The average pixel intensity of the frame, equal to averageBrightness. |
Returns
Type | Description |
---|---|
bool | true if the frame has an average brightness value. Otherwise, false. Equal to hasAverageBrightness. |
TryGetAverageColorTemperature(out float)
Get the estimated color temperature of the frame if possible.
Declaration
public bool TryGetAverageColorTemperature(out float averageColorTemperature)
Parameters
Type | Name | Description |
---|---|---|
float | averageColorTemperature | The estimated color temperature of the frame, in degrees Kelvin. Equal to averageColorTemperature. |
Returns
Type | Description |
---|---|
bool | true if the frame has an estimated color temperature value. Otherwise, false. Equal to hasAverageColorTemperature. |
TryGetAverageIntensityInLumens(out float)
Get the estimated intensity in lumens of the real-world environment, if possible.
Declaration
public bool TryGetAverageIntensityInLumens(out float averageIntensityInLumens)
Parameters
Type | Name | Description |
---|---|---|
float | averageIntensityInLumens | The estimated intensity. Equal to averageIntensityInLumens. |
Returns
Type | Description |
---|---|
bool | 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 |
---|---|---|
Matrix4x4 | displayMatrix | The display matrix. Equal to displayMatrix. |
Returns
Type | Description |
---|---|
bool | true if the frame has a display matrix. Otherwise, false. Equal to hasDisplayMatrix. |
TryGetExifData(out XRCameraFrameExifData)
Get the frame's EXIF data, if possible.
Declaration
public bool TryGetExifData(out XRCameraFrameExifData exifData)
Parameters
Type | Name | Description |
---|---|---|
XRCameraFrameExifData | exifData | The EXIF data. |
Returns
Type | Description |
---|---|
bool |
TryGetProjectionMatrix(out Matrix4x4)
Get the projection matrix for the frame if possible.
Declaration
public bool TryGetProjectionMatrix(out Matrix4x4 projectionMatrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix4x4 | projectionMatrix | The projection matrix. Equal to projectionMatrix. |
Returns
Type | Description |
---|---|
bool | true if the frame has a projection matrix. Otherwise, false. Equal to hasProjectionMatrix. |
TryGetTimestamp(out long)
Get the timestamp of the frame if possible.
Declaration
public bool TryGetTimestamp(out long timestampNs)
Parameters
Type | Name | Description |
---|---|---|
long | timestampNs | The timestamp of the camera frame, equal to timestampNs. |
Returns
Type | Description |
---|---|
bool | true if the frame has a timestamp. Otherwise, false. Equal to hasTimestamp. |
Operators
operator ==(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 |
---|---|
bool |
operator !=(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 |
---|---|
bool |