<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Cinematic",
  "identifier" : "/documentation/Cinematic/CNDetection-swift.struct/disparity(in:sourceDisparity:detectionType:priorDisparity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Cinematic"
    ],
    "preciseIdentifier" : "s:9Cinematic11CNDetectionV9disparity2in15sourceDisparity13detectionType05priorF0SfSo6CGRectV_So11CVBufferRefaSo0bH0VSfSgtFZ"
  },
  "title" : "disparity(in:sourceDisparity:detectionType:priorDisparity:)"
}
-->

# disparity(in:sourceDisparity:detectionType:priorDisparity:)

Determines the disparity to use to focus on the object in the rectangle.

```
static func disparity(in normalizedRect: CGRect, sourceDisparity: CVPixelBuffer, detectionType: CNDetectionType, priorDisparity: Float? = nil) -> Float
```

## Parameters

`normalizedRect`

The rectangle within the image where the object occurs, normalized such that (0.0, 0.0) is the top-left and (1.0, 1.0) is the bottom-right.

`sourceDisparity`

The disparity buffer containing depth information

`detectionType`

The type of object expected within the rectangle. Pass `CNDetectionTypeUnknown` if unknown.

`priorDisparity`

The disparity of the object in the prior frame. This helps ensure the object isn’t mistaken for another that enters the same rectangle. Pass `NAN` if there’s no known prior, such as in the first frame in which the tracked object.

## Return Value

A float representing the disparity to use to focus on the object in the rectangle.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)