簡體   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