0

how can I find focal length of iPhone camera lens. I already find out lens aperture value by this:- let aperture = currentcamera?.lensAperture
print("Aperture of camera is:-",aperture!)

Saurav_Sharma
  • 130
  • 1
  • 10

1 Answers1

1

To do this you need to first take an image from the camera, then read its focal-length property from the Exif data returned. Sample code is given here and copied below for reference:

// 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)")
}
Mohammad Assad Arshad
  • 1,535
  • 12
  • 14