gpt4 book ai didi

ios - 从 CMSampleBuffer 获取曝光时间 (EXIF)

转载 作者:行者123 更新时间:2023-12-01 17:54:28 25 4
gpt4 key购买 nike

我试图从使用 AVFoundation 捕获的图像中获取曝光时间.当我按照 2010 年的 WWDC 指令从 CMSampleBuffer 检索有用的图像元数据时像这样:

-(void)captureStillImageWithCompletion:(completion_exp)completionHandler
{
AVCaptureConnection *connection = [stillImage connectionWithMediaType:AVMediaTypeVideo];

typedef void(^MyBufBlock)(CMSampleBufferRef, NSError*);

MyBufBlock h = ^(CMSampleBufferRef buf, NSError *err){
CFDictionaryRef exifAttachments = CMGetAttachment(buf, kCGImagePropertyExifDictionary, NULL);
if(exifAttachments){
NSLog(@"%@",exifAttachments);
}

if(completionHandler){
completionHandler();
}
};

[stillImage captureStillImageAsynchronouslyFromConnection:connection completionHandler:h];
}

我在 CFDictionaryRef 上有一个错误线:

Cannot initialize a variable of type'CFDictionaryRef (aka 'const __CFDictionary*') with an rvalue of type CFTypeRef..

所以我在互联网上遵循了一个解决方案,如下所示:
CFDictionaryRef exifAttachments = (CFDictionaryRef)CMGetAttachment(buf, kCGImagePropertyExifDictionary, NULL);

现在它给了我另一个错误:Undefined symbols for architecture armv7s

(Apple Mach-o Linker Error: "_kCGImagePropertyExifDictionary", referenced from:)
(Apple Mach-o Linker Error: "_CMGetAttachment", referenced from:)

我不明白我的程序出了什么问题。有人有什么想法吗?

最佳答案

的修改版Philli's 回答 swift 4 :

var exifEd: Double?
if let metadata = CMGetAttachment(sampleBuffer, key: "{Exif}" as CFString, attachmentModeOut: nil) as? NSDictionary {
if let exposureDurationNumber = metadata.value(forKey: "ExposureTime") as? NSNumber {
exifEd = exposureDurationNumber.doubleValue
}
}

关于ios - 从 CMSampleBuffer 获取曝光时间 (EXIF),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20651592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com