Skip to content

Commit

Permalink
GPUImageVideoCamera makes the metadata from the image capture availab…
Browse files Browse the repository at this point in the history
…le during the capture completion handler
  • Loading branch information
brettg committed Nov 8, 2012
1 parent 82872b9 commit 2fc4a5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ - (IBAction)takePhoto:(id)sender;
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
// report_memory(@"After asset library creation");

[library writeImageDataToSavedPhotosAlbum:processedJPEG metadata:nil completionBlock:^(NSURL *assetURL, NSError *error2)
[library writeImageDataToSavedPhotosAlbum:processedJPEG metadata:stillCamera.currentCaptureMetadata completionBlock:^(NSURL *assetURL, NSError *error2)
{
// report_memory(@"After writing to library");
if (error2) {
Expand Down
3 changes: 3 additions & 0 deletions framework/Source/GPUImageStillCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ void GPUImageCreateResizedSampleBuffer(CVPixelBufferRef cameraFrame, CGSize fina

@interface GPUImageStillCamera : GPUImageVideoCamera

// Only reliably set inside the context of the completion handler of one of the capture methods
@property (readonly) NSDictionary *currentCaptureMetadata;

// Photography controls
- (void)capturePhotoAsSampleBufferWithCompletionHandler:(void (^)(CMSampleBufferRef imageSampleBuffer, NSError *error))block;
- (void)capturePhotoAsImageProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFilterInChain withCompletionHandler:(void (^)(UIImage *processedImage, NSError *error))block;
Expand Down
5 changes: 5 additions & 0 deletions framework/Source/GPUImageStillCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ - (void)capturePhotoProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)finalFi
}
}

CFDictionaryRef metadata = CMCopyDictionaryOfAttachments(NULL, imageSampleBuffer, kCMAttachmentMode_ShouldPropagate);
_currentCaptureMetadata = (__bridge_transfer NSDictionary *)metadata;

block(nil);

_currentCaptureMetadata = nil;
}];
}

Expand Down

0 comments on commit 2fc4a5c

Please sign in to comment.