58ef21ebfd
* docs: Link `videoHdr` * Update PERFORMANCE.mdx * docs: Add isActive to perf * docs: Update errors * feat: Add `minFocusDistance` prop * Format * Update Podfile.lock * fix: To Double * fix: Import AVFoundation * fix: Move from format -> device * fix: Use centi-meters (cm) instead of meters * Fix deadloop * fix: Avoid -1 values
26 lines
579 B
Swift
26 lines
579 B
Swift
//
|
|
// AVCaptureDevice+minFocusDistance.swift
|
|
// VisionCamera
|
|
//
|
|
// Created by Marc Rousavy on 15.01.24.
|
|
// Copyright © 2024 mrousavy. All rights reserved.
|
|
//
|
|
|
|
import AVFoundation
|
|
import Foundation
|
|
|
|
extension AVCaptureDevice {
|
|
/**
|
|
* The minimum distance this device can focus to, in centi-meters.
|
|
*/
|
|
var minFocusDistance: Double {
|
|
guard #available(iOS 15.0, *), minimumFocusDistance > 0 else {
|
|
// focus distance is unknown/unavailable
|
|
return 0
|
|
}
|
|
|
|
// convert from millimeters to centimeters
|
|
return Double(minimumFocusDistance) / 10
|
|
}
|
|
}
|