DetectLensSmudgeRequest
A request that detects a smudge on a lens from an image or video frame capture.
Declaration
struct DetectLensSmudgeRequestOverview
Use this request to detect whether an image or video is captured with a smudged lens. A smudge is anything that obscures a lens, like a fingerprint or raindrops, resulting in a hazy or blurry capture. Use this capability to find the best frame from a video or set of images.
Perform this request when detecting a smudge within an image or video frame. The request returns a SmudgeObservation. This observation contains a floating-point confidence value in the range of 0.0 to 1.0 indicating the probability that a capture has an impaired or smudged lens at capture time. A score of 1.0 represents a high probability the lens is smudged at capture time.
Running DetectLensSmudgeRequest requires a device with A14 Bionic and later or device with M1 and later.
To use the properties of the request, add a ImageProcessingRequest to your chosen capture type.
func isGoodCapture(imageURL:URL) async throws -> Bool {
// Set an optional threshold from 0.0 to 1.0 to flag a maximum level of smudge in your capture.
let smudgeThreshold: Float = 0.9;
let request = DetectLensSmudgeRequest(.revision1)
let smudgeObservation = try await request.perform(on: imageURL)
return (smudgeObservation.confidence < smudgeThreshold)
}Topics
Creating a request
Performing a request
perform(on:orientation:)perform(on:orientation:)perform(on:orientation:)perform(on:orientation:)perform(on:orientation:)perform(on:orientation:)