晚上好斯塔克沃夫的朋友们,
我一直试图找到精确的数据来计算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
但结果看上去非常不准确。我遗漏了什么吗?
发布于 2017-04-25 22:14:16
此页面(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
}
}https://stackoverflow.com/questions/43621664
复制相似问题