An observation that provides all of the detected contours in an image.
Contours can be referenced as a flattened array or as a tree of enclosing parent contours to enclosed child contours.
```
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
┌───────────────────┐ │
│ Λ │ ┌─────────┐ │
╱ ╲ │ │ │ │ │
│ ╱ ╲ │ │ │ │
╱ ╲ │ │ C │ │ │
│ ▕ A ▏ │ └─────────┘ │
╲ ╱ │ │ │
│ ╲ ╱ │ B │
╲ ╱ └───────────────────┘ │
│ V
│
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
```
Contour A index 0, index path [0].
Contour B index 1, index path [1].
Contour C index 2, index path [1, 0].
Members (11)
get · iOS 18.0+
topLevelContours
TypeScript
get topLevelContours(): Array<ContoursObservation_Contour>
Swift declaration
var topLevelContours: [ContoursObservation.Contour] { get }
An array of contours that don’t have another contour enclosing them.
This array constitutes the top of the contour hierarchy. You can iterate over each VNContour instance to determine its children.
get · iOS 18.0+
confidence
TypeScript
get confidence(): number
Swift declaration
let confidence: Float
The level of confidence normalized to `[0, 1]` where `1` is most confident.
The only exception is results coming from `CoreMLRequest`, where confidence values are forwarded as is from relevant CoreML models
get · iOS 18.0+
description
TypeScript
get description(): string
Swift declaration
var description: String { get }
A textual representation of this instance.
Calling this property directly is discouraged. Instead, convert an
instance of any type to a string by using the `String(describing:)`
initializer. This initializer works with any type, and uses the custom
`description` property for types that conform to
`CustomStringConvertible`:
struct Point: CustomStringConvertible {
let x: Int, y: Int
var description: String {
return "(\(x), \(y))"
}
}
let p = Point(x: 21, y: 30)
let s = String(describing: p)
print(s)
// Prints "(21, 30)"
The conversion of `p` to a string in the assignment to `s` uses the
`Point` type's `description` property.
get · iOS 18.0+
contourCount
TypeScript
get contourCount(): number
Swift declaration
var contourCount: Int { get }
The total number of detected contours.
Use this value to determine the number of indices available for calling `contour(at:)`.
Retrieves the contour object at the specified index, irrespective of hierarchy.
- Parameters:
- contourIndex: The index of the contour to retrieve. Valid values are in the range of 0 to contourCount - 1.
- Returns: The contour object at the specified index path, or `nil` if the index path is invalid.
get · iOS 18.0+
normalizedPath
TypeScript
get normalizedPath(): _CoreGraphics_CGPath
Swift declaration
var normalizedPath: CGPath { get }
The detected contours as a path object in normalized coordinates.
Retrieves the contour object at the specified index path.
- Parameters:
- indexPath: The hierarchical index path to the contour.
- Returns: The contour object at the specified index, or `nil` if the index is invalid.
get · iOS 18.0+
originatingRequestDescriptor
TypeScript
get originatingRequestDescriptor(): (RequestDescriptor) | null
Swift declaration
let originatingRequestDescriptor: RequestDescriptor?
The descriptor of the request that produced the observation.
get · iOS 18.0+
uuid
TypeScript
get uuid(): string
Swift declaration
let uuid: UUID
The unique identifier for the observation.
get · iOS 18.0+
timeRange
TypeScript
get timeRange(): (_CoreMedia_CMTimeRange) | null
Swift declaration
let timeRange: CMTimeRange?
The time range of the reported observation.
When evaluating a sequence of image buffers, use this property to determine each observation’s start time and duration.