Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created May 25, 2016 10:14
Show Gist options
  • Save quangtqag/d3533d9a6b0afa7c874dc56af1bf8afb to your computer and use it in GitHub Desktop.
Save quangtqag/d3533d9a6b0afa7c874dc56af1bf8afb to your computer and use it in GitHub Desktop.
func ciImageFromSampleBuffer(sampleBuffer: CMSampleBuffer) -> CIImage {
let pixelBuffer : CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)!
let attachments : CFDictionaryRef = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, pixelBuffer, CMAttachmentMode( kCMAttachmentMode_ShouldPropagate))!
let ciImage = CIImage(CVPixelBuffer: pixelBuffer, options: attachments as? [String : AnyObject])
return ciImage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment