One Logo Pool Ball
Vision · IOS API REFERENCE

DetectRectanglesRequest

struct · iOS 18.0+ · SDK 27.1

struct DetectRectanglesRequest

An image-analysis request that finds projected rectangular regions in an image. 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.

Members (19)

get · iOS 18.0+

descriptor

TypeScript
get descriptor(): RequestDescriptor
Swift declaration
var descriptor: RequestDescriptor { get }

An enum that identifies the request and request revision.

get · iOS 18.0+

minimumSize

TypeScript
get minimumSize(): number
Swift declaration
var minimumSize: Float

The minimum size of the rectangle detected as a proportion of the smallest dimension. The property's value defaults to `0.2`, but you can set it to any value in the range `[0.0, 1.0]`. Any smaller rectangles that Vision may detect aren’t returned.

set · iOS 18.0+

minimumSize

TypeScript
set minimumSize(value: number)
Swift declaration
var minimumSize: Float

The minimum size of the rectangle detected as a proportion of the smallest dimension. The property's value defaults to `0.2`, but you can set it to any value in the range `[0.0, 1.0]`. Any smaller rectangles that Vision may detect aren’t returned.

get · iOS 18.0+

regionOfInterest

TypeScript
get regionOfInterest(): NormalizedRect
Swift declaration
var regionOfInterest: NormalizedRect

The region of the image in which Vision will perform the request. The rectangle is normalized to the dimensions of the processed image. Its origin is specified relative to the image's lower-left corner. By default, the region of interest will be the full image.

set · iOS 18.0+

regionOfInterest

TypeScript
set regionOfInterest(value: NormalizedRect)
Swift declaration
var regionOfInterest: NormalizedRect

The region of the image in which Vision will perform the request. The rectangle is normalized to the dimensions of the processed image. Its origin is specified relative to the image's lower-left corner. By default, the region of interest will be the full image.

method · iOS 18.0+

setComputeDevice

TypeScript
setComputeDevice(computeDevice: (_CoreML_MLComputeDevice) | null, computeStage: ComputeStage): void
Swift declaration
mutating func setComputeDevice(_ computeDevice: MLComputeDevice?, for computeStage: ComputeStage)

Assigns a compute device for a compute stage. If the parameter `computeDevice` is `nil`, the framework removes any explicit compute device assignment and allows the framework to select the device. Configure any compute device for a given compute stage. When performing a request, the system makes a validity check. Use `supportedComputeStageDevices` to get valid compute devices for a request’s compute stages. - Parameters: - `computeDevice: `The compute device to assign to the compute stage. - `computeStage: `The compute stage.

get · iOS 18.0+

minimumConfidence

TypeScript
get minimumConfidence(): number
Swift declaration
var minimumConfidence: Float

The minimum acceptable confidence level for detected rectangles. Vision won’t return rectangles with a confidence score lower than the specified minimum. The property's default value is `0.0`, but you can set it to any value in the range `[0.0, 1.0]`. A value of `0.0` represents no confidence, while `1.0` represents full confidence.

set · iOS 18.0+

minimumConfidence

TypeScript
set minimumConfidence(value: number)
Swift declaration
var minimumConfidence: Float

The minimum acceptable confidence level for detected rectangles. Vision won’t return rectangles with a confidence score lower than the specified minimum. The property's default value is `0.0`, but you can set it to any value in the range `[0.0, 1.0]`. A value of `0.0` represents no confidence, while `1.0` represents full confidence.

get · iOS 18.0+

maximumAspectRatio

TypeScript
get maximumAspectRatio(): number
Swift declaration
var maximumAspectRatio: Float

The largest aspect ratio the rectangle request detects. The property's value defaults to `1.0`, but you can set it to any value in the range `[0.0, 1.0]`. You can use this value to choose specific rectangles in the detection like filtering out narrow rectangles by excluding small aspect ratios, or setting a range of `0.95` to `1.0` to select mostly squares.

set · iOS 18.0+

maximumAspectRatio

TypeScript
set maximumAspectRatio(value: number)
Swift declaration
var maximumAspectRatio: Float

The largest aspect ratio the rectangle request detects. The property's value defaults to `1.0`, but you can set it to any value in the range `[0.0, 1.0]`. You can use this value to choose specific rectangles in the detection like filtering out narrow rectangles by excluding small aspect ratios, or setting a range of `0.95` to `1.0` to select mostly squares.

get · iOS 18.0+

minimumAspectRatio

TypeScript
get minimumAspectRatio(): number
Swift declaration
var minimumAspectRatio: Float

The smallest aspect ratio the rectangle request detects. The property's value defaults to `0.5`, but you can set it to any value in the range `[0.0, 1.0]`. You can use this value to choose specific rectangles in the detection like filtering out narrow rectangles by excluding small aspect ratios, or setting a range of `0.95` to `1.0` to select mostly squares.

set · iOS 18.0+

minimumAspectRatio

TypeScript
set minimumAspectRatio(value: number)
Swift declaration
var minimumAspectRatio: Float

The smallest aspect ratio the rectangle request detects. The property's value defaults to `0.5`, but you can set it to any value in the range `[0.0, 1.0]`. You can use this value to choose specific rectangles in the detection like filtering out narrow rectangles by excluding small aspect ratios, or setting a range of `0.95` to `1.0` to select mostly squares.

get · iOS 18.0+

supportedRevisions

TypeScript
static get supportedRevisions(): Array<DetectRectanglesRequest_Revision>
Swift declaration
static let supportedRevisions: [DetectRectanglesRequest.Revision]

The collection of revisions the request supports.

get · iOS 18.0+

maximumObservations

TypeScript
get maximumObservations(): number
Swift declaration
var maximumObservations: Int

The maximum number of rectangles the request returns. The property's default value is `1`. Setting this property to `0` will return a potentially unlimited number of observations.

set · iOS 18.0+

maximumObservations

TypeScript
set maximumObservations(value: number)
Swift declaration
var maximumObservations: Int

The maximum number of rectangles the request returns. The property's default value is `1`. Setting this property to `0` will return a potentially unlimited number of observations.

get · iOS 18.0+

quadratureToleranceDegrees

TypeScript
get quadratureToleranceDegrees(): number
Swift declaration
var quadratureToleranceDegrees: Float

The maximum number of degrees a rectangle corner angle deviates from 90°. The property's value defaults to `30`, but you can set it to any value in the range `[0, 45]`.

set · iOS 18.0+

quadratureToleranceDegrees

TypeScript
set quadratureToleranceDegrees(value: number)
Swift declaration
var quadratureToleranceDegrees: Float

The maximum number of degrees a rectangle corner angle deviates from 90°. The property's value defaults to `30`, but you can set it to any value in the range `[0, 45]`.

get · iOS 18.0+

revision

TypeScript
get revision(): DetectRectanglesRequest_Revision
Swift declaration
let revision: DetectRectanglesRequest.Revision

The request's configured revision.

init · iOS 18.0+

init

TypeScript
static init(revision?: (DetectRectanglesRequest_Revision) | null): DetectRectanglesRequest
Swift declaration
init(_ revision: DetectRectanglesRequest.Revision? = nil)

Creates a rectangle-detection request. - Parameters: - revision: The specific algorithm or implementation revision that's used to perform the request.

Skipped declarations

No declarations were skipped in this snapshot.

All Vision types →