3
我使用AVFoundation捕獲UIView中的圖像並添加註釋。現在,我需要獲取捕獲圖像的地理位置。我現在的代碼片段如下所示。元數據不具有地理位置。也許我將不得不使用CLLocation?請儘快指導我。獲取使用AVFoundation的AVCaptureStillImageOutput獲取的圖像的地理位置
[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];
}];