我到处寻找相机的焦距和后传感器的高度。 但我没有得到任何具体细节。
我正在开发一款应用程序,该应用程序将根据从 ios 相机捕获的图像中的可见高度计算真实世界对象的实际高度。
到物体的距离(毫米)=
焦距(mm)*物体真实高度(mm)*像高(像素)------------------------ ----------------------------------------------
物体高度(像素)*传感器高度(mm)
这里我将到对象的距离值设置为静态值,以像素为单位的图像高度。现在我需要焦距和传感器高度来找出真实物体的高度。
提前致谢。 斯卡尼亚
最佳答案
EXIF header
iOS 设备在 JPEG EXIF header 中提供相机的焦距值。它在 iPhoto
和任何其他工具中可见。
以编程方式检索它的选项
- Apple Technical Q&A QA1622讨论 ALAssetsLibrary
- Accessing Image Properties使用 CGImageSourceRef
EXIF header key 列表可以在 CGImageProperties Reference 中找到.
NSURL *imageFileURL = [NSURL fileURLWithPath:...];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)imageFileURL, NULL);
if (imageSource == NULL) {
// Error loading image
...
return;
}
NSDictionary *options = @{kCGImageSourceShouldCache, @NO};
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (CFDictionaryRef)options);
if (imageProperties) {
NSNumber *width = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
NSNumber *height = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
NSLog(@"Image dimensions: %@ x %@ px", width, height);
CFRelease(imageProperties);
}
CFRelease(imageSource);
关于ios - 如何找出ios中相机的焦距以及传感器高度是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13190932/