Skip to content

About

On-device, license-clean cinematic background blur driven by a monocular depth map (Depth Anything V2) — subject stays sharp, background softens with distance.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

swift-depth-blur

On-device, license-clean cinematic background blur driven by a monocular depth map — near stays sharp, far goes soft, with a real gradual falloff (not a hard person cutout, and it works on any scene).

  • DepthEstimator — wraps Apple's Depth Anything V2 Core ML model (Apache), ~50 MB, image → depth map via Vision (~tens of ms warm on the Neural Engine).
  • DepthBlurFilter — turns the depth into a per-pixel blur mask (sharp at the focal plane, blurrier with distance) and runs CIMaskedVariableBlur.
  • DepthBlur — Codable settings: amount, focalPlane, falloff.
let estimator = try DepthEstimator(modelURL: modelURL)   // DepthAnythingV2SmallF16.mlpackage
if let filter = DepthBlurFilter(settings: DepthBlur(amount: 0.6), estimator: estimator) {
    let out = filter.apply(sourceImage)   // per-frame; source space
}

Model: apple/coreml-depth-anything-v2-small on Hugging Face (not committed). Requirements: macOS 26 / iOS 26, Swift 6.2.

License

MIT — see LICENSE.

Bundled or downloaded models keep their own licences; see the notes above where a model is named.

About

On-device, license-clean cinematic background blur driven by a monocular depth map (Depth Anything V2) — subject stays sharp, background softens with distance.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages