Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Convert AVCaptureStillImageOutput to UIImage without lose resolution
- func imageFromSampleBuffer(sampleBuffer : CMSampleBuffer) -> UIImage
- {
- // convert UIImage without lose quality
- let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
- let ciImage = CIImage.init(cvPixelBuffer: pixelBuffer!)
- let context = CIContext.init()
- let width = CVPixelBufferGetWidth(pixelBuffer!)
- let height = CVPixelBufferGetHeight(pixelBuffer!)
- let cgImage = context.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: width, height: height))
- let image = UIImage.init(cgImage: cgImage!);
- return (image)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement