# GARFrame(Semantics)

Category adding Semantics functionality to `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame`.

## Summary

| ### Properties ||
|---|---|
| `https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#semanticconfidenceimage` | `CVPixelBufferRef` The latest semantic confidence image for the `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame` as a [`CVPixelBuffer`](https://developer.apple.com/documentation/corevideo/cvpixelbuffer). |
| `https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#semanticimage` | `CVPixelBufferRef` The latest semantic image for the `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame` as a [`CVPixelBuffer`](https://developer.apple.com/documentation/corevideo/cvpixelbuffer). |

| ### Public methods ||
|---|---|
| `https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#fractionforsemanticlabel:` | `float` Retrieves the fraction of the most recent semantics frame that are `queryLabel`. |

## Properties

### semanticConfidenceImage

```
@property(nullable, readonly) CVPixelBufferRef semanticConfidenceImage CF_RETURNS_NOT_RETAINED;
```
The latest semantic confidence image for the `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame` as a [`CVPixelBuffer`](https://developer.apple.com/documentation/corevideo/cvpixelbuffer).

Each pixel is an 8-bit integer representing the confidence of the semantic label, with 0 representing the lowest confidence and 255 representing the highest confidence.

`https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame` retains the semantic `CVPixelBuffer`. Holding references to `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame`s will eventually exhaust resources.

`https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#semanticconfidenceimage` will be nil if `https://developers.google.com/ar/reference/ios/interface/GARSessionConfiguration#interface_g_a_r_session_configuration` does not have `https://developers.google.com/ar/reference/ios/group/GARSemanticMode#garsemanticmodeenabled` set. Use `https://developers.google.com/ar/reference/ios/category/GARSession(Semantics)#issemanticmodesupported:` to check for support for the Scene Semantics API.

`https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#semanticconfidenceimage` may be nil for the first few frames after initializing semantics, or if memory is exhausted due to retaining old `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame`s.
Extends class `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame_1aba2335384b07d882ebc284158fa697f9`.

### semanticImage

```
@property(nullable, readonly) CVPixelBufferRef semanticImage CF_RETURNS_NOT_RETAINED;
```
The latest semantic image for the `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame` as a [`CVPixelBuffer`](https://developer.apple.com/documentation/corevideo/cvpixelbuffer).

Each pixel in the image is an 8-bit integer representing a semantic class label: see `https://developers.google.com/ar/reference/ios/group/GARSemanticLabel#garsemanticlabel` for a list of pixel labels and [the Scene Semantics Developer Guide](https://developers.google.com/ar/develop/ios/scene-semantics) for more information.

`https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame` retains the semantic `CVPixelBuffer`. Holding references to `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame`s will eventually exhaust resources.

`https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#semanticimage` will be nil if `https://developers.google.com/ar/reference/ios/interface/GARSessionConfiguration#interface_g_a_r_session_configuration` does not have `https://developers.google.com/ar/reference/ios/group/GARSemanticMode#garsemanticmodeenabled` set. Use `https://developers.google.com/ar/reference/ios/category/GARSession(Semantics)#issemanticmodesupported:` to check for support for the Scene Semantics API.

`https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#semanticimage` may be nil for the first few frames after initializing semantics, or if memory is exhausted due to retaining old `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame`s.
Extends class `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame_1ae4f7b3d8df273c055755b2433e97dd64`.

## Public methods

### fractionForSemanticLabel:

```
- (float)fractionForSemanticLabel:(https://developers.google.com/ar/reference/ios/group/GARSemanticLabel#garsemanticlabel) queryLabel
```
Retrieves the fraction of the most recent semantics frame that are `queryLabel`.

Queries the semantic image provided by `https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#semanticimage` for pixels labeled by `queryLabel`. This call is more efficient than retrieving the `CVPixelBuffer` and performing a pixel-wise search for the detected labels.

If `https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#semanticimage` is nil, `https://developers.google.com/ar/reference/ios/category/GARFrame(Semantics)#fractionforsemanticlabel:` will return 0.0.


Details Parameters `queryLabel` the label to search for in the semantic image. See `https://developers.google.com/ar/reference/ios/group/GARSemanticLabel#garsemanticlabel` for options. **Returns** The fraction of the semantic image with the given `queryLabel`. Extends class `https://developers.google.com/ar/reference/ios/interface/GARFrame#interface_g_a_r_frame_1a20c44998075101f44c360592025b2ed4`.