2012-07-12 4 views
3

AVFoundation을 사용하여 UIView에서 이미지를 캡처하고 주석을 추가했습니다. 이제 캡처 한 이미지의 위치 정보를 가져와야합니다. 현재 코드 스 니펫은 아래와 같습니다. 메타 데이터에 Geolocation이 없습니다. 어쩌면 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]; 
}]; 

답변

0

내가 알 수있는 것부터, 자신의 메타 데이터 사전을 랩핑하고 이미지 데이터에 추가해야합니다. 여기

은 클래스 확장 (구스타보함으로써, 아래 링크)을 AVCaptureStillImageOutput API를 사용하여 캡처 사진에 기록하기 EXIF ​​및 위치 정보 데이터를 처리합니다 또한 https://github.com/gpambrozio/GusUtils/blob/master/GusUtils/NSMutableDictionary+ImageMetadata.m

을 여기에 구현 설명 구스타보의 기사입니다 : http://blog.codecropper.com/2011/05/adding-metadata-to-ios-images-the-easy-way/

HTH

관련 문제