Created
May 25, 2016 10:13
-
-
Save quangtqag/912b2ab13daf421320ce4158a884095d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func cgImageFromSampleBuffer(sampleBuffer: CMSampleBuffer) -> CGImage { | |
let pixelBuffer : CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)! | |
let ciImage = CIImage(CVPixelBuffer: pixelBuffer) | |
let context: CIContext = CIContext(options: nil) | |
let rect = CGRectMake(0, 0, CGFloat(CVPixelBufferGetWidth(pixelBuffer)), CGFloat(CVPixelBufferGetHeight(pixelBuffer))) | |
let cgImage = context.createCGImage(ciImage, fromRect: rect) | |
return cgImage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment