react-native-vision-camera/package/ios/Extensions/AVCaptureDevice+minFocusDistance.swift
Marc Rousavy 58ef21ebfd
feat: Add minFocusDistance prop to CameraDevice (#2392)
* 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
2024-01-15 19:30:20 +01:00

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
}
}