相机参数 - iPhone 7

时间:2017-04-25 21:57:33

标签: ios iphone opencv

Stackoverflow晚上好人,

我一直试图找到准确的数据来计算CameraParams的焦点参数很长一段时间,但是却积极失败。

这是我到目前为止所得到的:

iPhone 7
Sensor width: 3.99mm
Focal length: 7.21mm
Random image: 400x400

计算:

focal(in pixel) = image width(in pixel)*focal(in mm)/sensor width(mm)

focal = 400 * 7.21 / 3.99

但结果看起来非常不准确。有什么我想念的吗?

1 个答案:

答案 0 :(得分:1)

此页面(https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Cameras/Cameras.html)为您提供了每款iPhone相机型号的规格。

拍摄照片时,您还可以使用以下代码获取相机的规格。

private func getCaptureDeviceSpec(_ videoDevice : AVCaptureDevice?) {
    if let deviceFormats = videoDevice?.formats {
        var width : Float = 0
        var height : Float = 0
        var fov : Float = 0
        for format in deviceFormats {
            if let deviceFormat = (format as? AVCaptureDeviceFormat) {
                let dim = deviceFormat.highResolutionStillImageDimensions
                if width < Float(dim.width) && height < Float(dim.height) {
                    width = Float(dim.width)
                    height = Float(dim.height)
                    fov = deviceFormat.videoFieldOfView
                }
            }
        }
        cameraSpec.width = width
        cameraSpec.height = height
        cameraSpec.fov = fov
    }
}