Skip to content

Instantly share code, notes, and snippets.

@danlipert
Last active December 12, 2015 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danlipert/4694932 to your computer and use it in GitHub Desktop.
Save danlipert/4694932 to your computer and use it in GitHub Desktop.
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:videoConnection
completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
if(!error)
{
if(imageSampleBuffer != NULL)
{
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
NSLog(@"Captured image size: %f, %f", image.size.width, image.size.height);
[self setStillImage:image];
[image release];
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate photoCaptureSessionDidCaptureImage:self.stillImage withOrientation:orientation];
});
}
} else {
NSLog(@"ERROR TAKING PHOTO");
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment