Ios 获取使用AVFoundation';s AVCaptureStillImageOutput
我使用AVFoundation在UIView中捕获图像并添加注释。现在,我需要得到拍摄图像的地理位置。我当前的代码片段如下所示。元数据没有地理位置。也许我必须使用CLLocation?请尽快引导我Ios 获取使用AVFoundation';s AVCaptureStillImageOutput,ios,geolocation,avfoundation,Ios,Geolocation,Avfoundation,我使用AVFoundation在UIView中捕获图像并添加注释。现在,我需要得到拍摄图像的地理位置。我当前的代码片段如下所示。元数据没有地理位置。也许我必须使用CLLocation?请尽快引导我 [stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *erro
[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捕获的照片: 另外,这里是Gustavo的文章,解释了实现: 嗯