晚上好,Stackoverflow 的 friend 们,
我一直在努力寻找准确的数据来计算 CameraParams 的焦点参数很长一段时间但积极失败。
这是我到目前为止得到的:
iPhone 7
Sensor width: 3.99mm
Focal length: 7.21mm
Random image: 400x400
计算:
焦距(像素)= 图像宽度(像素)*焦距(mm)/传感器宽度(mm)
焦点 = 400 * 7.21/3.99
但这样的结果看起来非常不准确。有什么我想念的吗?
最佳答案
此页面 ( 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
}
}
关于ios - 相机参数 - iPhone 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43621664/