title: How to create CGImage from CVPixelBuffer?
body: <p>I have a simple function to create <code>CGImage</code> from <code>CVPixelBuffer</code>:</p>
  <pre><code>if let buffer = (results as? [VNPixelBufferObservation])?.first {
      let pixelBuffer = buffer.pixelBuffer
      let ciImage = CIImage(cvPixelBuffer: pixelBuffer)
      let resultImage = UIImage(ciImage: ciImage)
      return resultImage.cgImage //returns nil
  }
  </code></pre>
  <p>But it returns nil. Why?</p>