<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureDevice/setCameraLensSmudgeDetectionEnabled(_:detectionInterval:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureDevice(im)setCameraLensSmudgeDetectionEnabled:detectionInterval:"
  },
  "title" : "setCameraLensSmudgeDetectionEnabled(_:detectionInterval:)"
}
-->

# setCameraLensSmudgeDetectionEnabled(_:detectionInterval:)

Specify whether to enable camera lens smudge detection, and the interval time between each run of detections.

```
func setCameraLensSmudgeDetectionEnabled(_ cameraLensSmudgeDetectionEnabled: Bool, detectionInterval: CMTime)
```

## Parameters

`cameraLensSmudgeDetectionEnabled`

Specify whether camera lens smudge detection should be enabled.

`detectionInterval`

The detection running interval if detection is enabled.

## Discussion

Each run of detection processes frames over a short period, and produces one detection result. Use `detectionInterval` to specify the interval time between each run of detections. For example, when [`isCameraLensSmudgeDetectionEnabled`](/documentation/AVFoundation/AVCaptureDevice/isCameraLensSmudgeDetectionEnabled) is set to `true` and `detectionInterval` is set to 1 minute, detection runs once per minute, and updates [`AVCaptureCameraLensSmudgeDetectionStatus`](/documentation/AVFoundation/AVCaptureCameraLensSmudgeDetectionStatus). If `detectionInterval` is set to `kCMTimeInvalid`, detection runs only once after the session starts. If `detectionInterval` is set to `kCMTimeZero`, detection runs continuously.

[`AVCaptureDevice`](/documentation/AVFoundation/AVCaptureDevice) throws an `NSInvalidArgumentException` if the [`isCameraLensSmudgeDetectionSupported`](/documentation/AVFoundation/AVCaptureDevice/Format/isCameraLensSmudgeDetectionSupported) property on the current active format returns `false`. Enabling detection requires a lengthy reconfiguration of the capture render pipeline, so you should enable detection before calling [`startRunning()`](/documentation/AVFoundation/AVCaptureSession/startRunning()) or within [`beginConfiguration()`](/documentation/AVFoundation/AVCaptureSession/beginConfiguration()) and [`commitConfiguration()`](/documentation/AVFoundation/AVCaptureSession/commitConfiguration()) while running.

---

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)