CIImage to CVPixelBuffer

MLBoy
1 min readAug 23, 2020

--

  1. Make CVPixel Buffer.
var pixelBuffer: CVPixelBuffer?
let attrs = [kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue,
kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue] as CFDictionary
let width:Int = Int(size.width)let height:Int = Int(size.height)CVPixelBufferCreate(kCFAllocatorDefault,
width,
height,
kCVPixelFormatType_32BGRA,
attrs,
&pixelBuffer)

2, Render CIImage to CVPixelBuffer.

let context = CIContext()
context.render(ciImage, to: pixelBuffer!)

****

We send information related to machine learning.

Twitter

contact:

rockyshikoku@gmail.com

--

--

MLBoy
MLBoy

No responses yet