如何使用AVFoundation获取iPhone相机的焦距

问题描述 投票:0回答:1

如何找到iPhone相机镜头的焦距。我已经通过以下方法找出了镜头光圈值:let aperture = currentcamera?.lensApertureprint("Aperture of camera is:-",aperture!)

ios swift xcode avfoundation avcapture
1个回答
0
投票

为此,您首先需要从相机拍摄图像,然后从返回的Exif数据中读取其焦距属性。给出了示例代码here,并在下面复制以供参考:

// delegate method for the image picker
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    let metadata = info[UIImagePickerControllerMediaMetadata] as? NSDictionary
    let exifdata = metadata!["{Exif}"] as! NSDictionary

    // focal length
    let focalLength = exifdata["FocalLength"] as! Double

    print("Focal length \(focalLength)")
}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.