gpt4 book ai didi

ios - 获取使用 AVFoundation 的 AVCaptureStillImageOutput 捕获的图像的地理定位

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:57 27 4
gpt4 key购买 nike

我使用 AVFoundation 在 UIView 中捕获图像并向其添加注释。现在,我需要获取拍摄图像的地理位置。我当前的代码片段如下所示。元数据没有地理位置。也许我将不得不使用 CLLocation?请尽快指导我。

[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
CFDictionaryRef metadataDict = CMCopyDictionaryOfAttachments(NULL, imageSampleBuffer, kCMAttachmentMode_ShouldPropagate);
NSMutableDictionary *metadata = [[NSMutableDictionary alloc] initWithDictionary:(__bridge NSDictionary*)metadataDict];
CFRelease(metadataDict);
NSLog(@"%@",metadata);
CFDictionaryRef exifAttachments = CMGetAttachment( imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
if (exifAttachments)
{
// Do something with the attachments.
}
else
NSLog(@"no attachments");

NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
[captureSession stopRunning];
[imageData writeToFile:path atomically:YES];
}];

最佳答案

据我所知,您必须包装自己的元数据字典并将其添加到图像数据中。

这是一个类扩展(由 Gustavo 提供,链接如下)处理将 EXIF 和地理定位数据写入使用 AVCaptureStillImageOutput api 捕获的照片:https://github.com/gpambrozio/GusUtils/blob/master/GusUtils/NSMutableDictionary+ImageMetadata.m

另外,这里是 Gustavo 的解释实现的文章:http://blog.codecropper.com/2011/05/adding-metadata-to-ios-images-the-easy-way/

HTH

关于ios - 获取使用 AVFoundation 的 AVCaptureStillImageOutput 捕获的图像的地理定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11450501/

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