2023-09-21 08:29:46 -06:00
|
|
|
//
|
|
|
|
// AVCaptureDevice+toDictionary.swift
|
|
|
|
// VisionCamera
|
|
|
|
//
|
|
|
|
// Created by Marc Rousavy on 21.09.23.
|
|
|
|
// Copyright © 2023 mrousavy. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import AVFoundation
|
|
|
|
|
|
|
|
extension AVCaptureDevice {
|
|
|
|
func toDictionary() -> [String: Any] {
|
2023-11-24 10:20:56 -07:00
|
|
|
let formats = formats.map { CameraDeviceFormat(fromFormat: $0) }
|
2023-10-13 10:33:20 -06:00
|
|
|
|
2023-09-21 08:29:46 -06:00
|
|
|
return [
|
|
|
|
"id": uniqueID,
|
|
|
|
"physicalDevices": physicalDevices.map(\.deviceType.physicalDeviceDescriptor),
|
|
|
|
"position": position.descriptor,
|
|
|
|
"name": localizedName,
|
|
|
|
"hasFlash": hasFlash,
|
|
|
|
"hasTorch": hasTorch,
|
|
|
|
"minZoom": minAvailableVideoZoomFactor,
|
|
|
|
"maxZoom": maxAvailableVideoZoomFactor,
|
2023-11-24 10:20:56 -07:00
|
|
|
"neutralZoom": neutralZoomFactor,
|
|
|
|
"minExposure": minExposureTargetBias,
|
|
|
|
"maxExposure": maxExposureTargetBias,
|
2023-09-21 08:29:46 -06:00
|
|
|
"isMultiCam": isMultiCam,
|
|
|
|
"supportsRawCapture": false, // TODO: supportsRawCapture
|
|
|
|
"supportsLowLightBoost": isLowLightBoostSupported,
|
|
|
|
"supportsFocus": isFocusPointOfInterestSupported,
|
|
|
|
"hardwareLevel": "full",
|
2023-10-19 09:02:07 -06:00
|
|
|
// TODO: Get orientation from `AVCaptureDevice.RotationCoordinator`, then just transform `AVAssetWriter`
|
|
|
|
// See https://github.com/mrousavy/react-native-vision-camera/issues/2046
|
|
|
|
"sensorOrientation": Orientation.landscapeRight.jsValue,
|
2023-10-13 10:33:20 -06:00
|
|
|
"formats": formats.map { $0.toJSValue() },
|
2023-09-21 08:29:46 -06:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|