# ARSemanticManager

Provides access to the Scene Semantics API.

## Summary

### Inheritance

Inherits from: [`UnityEngine::MonoBehaviour`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.html)

| ### Public functions ||
|---|---|
| `https://developers.google.com/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/ARSemanticManager#getsemanticlabelfraction(https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#semanticlabel queryLabel)` | `float` Retrieves the percentage of pixels in the most recent semantics image that are `queryLabel`. |
| `https://developers.google.com/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/ARSemanticManager#issemanticmodesupported(https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#semanticmode mode)` | `https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#featuresupported` Checks whether the provided `https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#semanticmode` is supported on this device with the selected camera configuration. |
| `https://developers.google.com/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/ARSemanticManager#trygetsemanticconfidencetexture(ref https://docs.unity3d.com/ScriptReference/Texture2D.html texture)` | `bool` Attempts to get a texture representing the semantic confidence image corresponding to the current frame. |
| `https://developers.google.com/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/ARSemanticManager#trygetsemantictexture(ref https://docs.unity3d.com/ScriptReference/Texture2D.html texture)` | `bool` Attempts to get a texture representing the semantic image for the current frame. |

## Public functions

### GetSemanticLabelFraction

```c#
float GetSemanticLabelFraction(
  SemanticLabel queryLabel
)
```
Retrieves the percentage of pixels in the most recent semantics image that are `queryLabel`.

This call is more efficient than retrieving the image and performing a pixel-wise search for the detected label.


Details Parameters `queryLabel` The `https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#semanticlabel` to search for within the semantic image for this frame. **Returns** The fraction of pixels in the most recent semantic image that contains the query label. This value is in the range 0.0 to 1.0. If no pixels are present with that label, or if an invalid label is provided, this call returns 0.0.

### IsSemanticModeSupported

```c#
FeatureSupported IsSemanticModeSupported(
  SemanticMode mode
)
```
Checks whether the provided `https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#semanticmode` is supported on this device with the selected camera configuration.

The current list of supported devices is documented on the [ARCore supported devices](https://developers.google.com/ar/devices) page.


Details Parameters `mode` The desired semantic mode. **Returns** Indicates whether the given mode is supported on this device. It will return `FeatureSupported.Unknown` if the session is still under initialization.

### TryGetSemanticConfidenceTexture

```c#
bool TryGetSemanticConfidenceTexture(
  ref Texture2D texture
)
```
Attempts to get a texture representing the semantic confidence image corresponding to the current frame.

The texture format is `TextureFormat.Alpha8`, with each pixel representing the estimated confidence of the corresponding pixel in the semantic image. See the [Scene Semantics Developer Guide](https://developers.google.com/ar/develop/unity-arf/scene-semantics) for more information.

The confidence value is between 0 and 255, inclusive, with 0 representing the lowest confidence and 255 representing the highest confidence in the semantic class prediction.

In order to obtain a valid result from this function, you must set the session's `https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#semanticmode` to `SemanticMode.Enabled`. Use `https://developers.google.com/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/ARSemanticManager#issemanticmodesupported` to query for support for Scene Semantics.

The size of the semantic confidence image is the same size as the image obtained by `https://developers.google.com/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/ARSemanticManager#trygetsemantictexture`.


Details Parameters `texture` The semantic confidence image `Texture2D` to be filled. **Returns** True if the semantic confidence image texture was filled. Otherwise, false.

### TryGetSemanticTexture

```c#
bool TryGetSemanticTexture(
  ref Texture2D texture
)
```
Attempts to get a texture representing the semantic image for the current frame.

The texture format is `TextureFormat.R8`. Each pixel in the image is an 8-bit unsigned integer representing a semantic class label. `https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#semanticlabel` is the list of possible pixel labels. See the [Scene Semantics Developer Guide](https://developers.google.com/ar/develop/unity-arf/scene-semantics) for more information.

In order to obtain a valid result from this function, you must set the session's `https://developers.google.com/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#semanticmode` to `SemanticMode.Enabled`. Use `https://developers.google.com/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/ARSemanticManager#issemanticmodesupported` to query for support for Scene Semantics.

The width of the semantic image is currently 256 pixels. The height of the image depends on the device and will match its display aspect ratio.


Details Parameters `texture` The semantic image `Texture2D` to be filled. **Returns** True if the semantic image texture was filled. Otherwise, false.