【问题标题】:Get Geolocation for image captured using AVFoundation's AVCaptureStillImageOutput获取使用 AVFoundation 的 AVCaptureStillImageOutput 捕获的图像的地理位置
【发布时间】:2012-07-12 11:06:23
【问题描述】:

我使用 AVFoundation 在 UIView 中捕获图像并向其中添加 cmets。现在,我需要获取捕获图像的地理位置。我当前的代码 sn -p 如下图所示。元数据没有地理位置。也许我将不得不使用 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];
 }];

【问题讨论】:

    标签: ios geolocation avfoundation


    【解决方案1】:

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

    这是一个类扩展(由 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多