繁体   English   中英

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

[英]how to get focal length of camera of iPhone using AVFoundation

如何找到 iPhone 相机镜头的焦距。 我已经通过这个找到了镜头光圈值:- let aperture = currentcamera?.lensAperture
print("Aperture of camera is:-",aperture!)

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

// 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)")
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM