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

# DetectRectanglesRequest

An image-analysis request that finds projected rectangular regions in an image.

```
struct DetectRectanglesRequest
```

## Overview

A rectangle-detection request locates regions of an image with a rectangular shape, like credit cards,
business cards, documents, and signs. The request returns its observations in the form of [RectangleObservation](https://developer.apple.com/documentation/vision/rectangleobservation) objects, which contain normalized
coordinates of bounding boxes containing a rectangle.

Use this type of request to find the bounding boxes of rectangles in an image. Vision returns observations
for rectangles found in all orientations and sizes, along with a confidence level to indicate how likely the observation contains an actual rectangle.

To further configure or restrict the types of rectangles found, set properties on the request specifying a
range of aspect ratios, sizes, and quadrature tolerance.

## Topics

### Creating a request

[`init(_:)`](/documentation/Vision/DetectRectanglesRequest/init(_:))

Creates a rectangle-detection request.

### Performing a request

[`perform(on:orientation:)`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-80bya)

Performs the request on an image URL and produces observations.

[`perform(on:orientation:)`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-3f3f1)

Performs the request on image data and produces observations.

[`perform(on:orientation:)`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-qxxx)

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

[`perform(on:orientation:)`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-xspx)

Performs the request on a pixel buffer and produces observations.

[`perform(on:orientation:)`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-3hddl)

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

[`perform(on:orientation:)`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-85ex1)

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

### Understanding the result

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

An object that represents the four vertices of a detected rectangle.

### Configuring a request

[`maximumAspectRatio`](/documentation/Vision/DetectRectanglesRequest/maximumAspectRatio)

The largest aspect ratio the rectangle request detects.

[`maximumObservations`](/documentation/Vision/DetectRectanglesRequest/maximumObservations)

The maximum number of rectangles the request returns.

[`minimumAspectRatio`](/documentation/Vision/DetectRectanglesRequest/minimumAspectRatio)

The smallest aspect ratio the rectangle request detects.

[`minimumConfidence`](/documentation/Vision/DetectRectanglesRequest/minimumConfidence)

The minimum acceptable confidence level for detected rectangles.

[`minimumSize`](/documentation/Vision/DetectRectanglesRequest/minimumSize)

The minimum size of the rectangle detected as a proportion of the smallest dimension.

[`quadratureToleranceDegrees`](/documentation/Vision/DetectRectanglesRequest/quadratureToleranceDegrees)

The maximum number of degrees a rectangle corner angle deviates from 90°.

### Getting the revision

[`revision`](/documentation/Vision/DetectRectanglesRequest/revision-swift.property)

The request’s configured revision.

[`supportedRevisions`](/documentation/Vision/DetectRectanglesRequest/supportedRevisions)

The collection of revisions the request supports.

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

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

## Relationships

### Conforms To

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

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

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

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

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

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

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

---

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)