<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Vision",
  "identifier" : "/documentation/Vision/TrackOpticalFlowRequest",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Vision"
    ],
    "preciseIdentifier" : "s:6Vision23TrackOpticalFlowRequestC"
  },
  "title" : "TrackOpticalFlowRequest"
}
-->

# TrackOpticalFlowRequest

A request that determines the direction change of vectors for each pixel from a previous to current image.

```
final class TrackOpticalFlowRequest
```

## Overview

This request generates an [`OpticalFlowObservation`](/documentation/Vision/OpticalFlowObservation) object that describes the directional change from image to image. The request works at the pixel level, so both images needs to have the same dimensions to successfully perform the request.

> Important:
> Optical flow requests are very resource intensive, so perform only one request at a time. Release memory immediately after generating an optical flow.

## Topics

### Creating a request

[`init(TrackOpticalFlowRequest.Revision?, frameAnalysisSpacing: CMTime?)`](/documentation/Vision/TrackOpticalFlowRequest/init(_:frameAnalysisSpacing:))

Creates an optical-flow tracking request.

### Performing a request

[`func perform(on: URL, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-80bya)

Performs the request on an image URL and produces observations.

[`func perform(on: Data, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-3f3f1)

Performs the request on image data and produces observations.

[`func perform(on: CGImage, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-qxxx)

Performs the request on a Core Graphics image and produces observations.

[`func perform(on: CVPixelBuffer, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-xspx)

Performs the request on a pixel buffer and produces observations.

[`func perform(on: CMSampleBuffer, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-3hddl)

Performs the request on a Core Media buffer and produces observations.

[`func perform(on: CIImage, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-85ex1)

Performs the request on a Core Image image and produces observations.

### Understanding the result

[`struct OpticalFlowObservation`](/documentation/Vision/OpticalFlowObservation)

An object that represents an optical flow that an image-analysis request produces.

### Configuring a request

[`var computationAccuracy: TrackOpticalFlowRequest.ComputationAccuracy`](/documentation/Vision/TrackOpticalFlowRequest/computationAccuracy-swift.property)

The level of accuracy to compute the optical flow.

[`enum ComputationAccuracy`](/documentation/Vision/TrackOpticalFlowRequest/ComputationAccuracy-swift.enum)

A type that describes the computational accuracy.

[`var outputPixelFormatType: OSType`](/documentation/Vision/TrackOpticalFlowRequest/outputPixelFormatType)

The desired pixel format type of the observation.

[`var supportedOutputPixelFormatTypes: [OSType]`](/documentation/Vision/TrackOpticalFlowRequest/supportedOutputPixelFormatTypes)

The collection of supported pixel format types.

### Getting the revision

[`let revision: TrackOpticalFlowRequest.Revision`](/documentation/Vision/TrackOpticalFlowRequest/revision-swift.property)

The algorithm or implementation the request uses.

[`static let supportedRevisions: [TrackOpticalFlowRequest.Revision]`](/documentation/Vision/TrackOpticalFlowRequest/supportedRevisions)

The collection of revisions the request supports.

[`enum Revision`](/documentation/Vision/TrackOpticalFlowRequest/Revision-swift.enum)

A type that describes the algorithm or implementation that the request performs.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`TargetedRequest`](/documentation/Vision/TargetedRequest)

[`StatefulRequest`](/documentation/Vision/StatefulRequest)

[`VisionRequest`](/documentation/Vision/VisionRequest)

[`Sendable`](/documentation/Swift/Sendable)

[`ImageProcessingRequest`](/documentation/Vision/ImageProcessingRequest)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

---

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)