title: How do you get an UIImage from an AVCaptureVideoPreviewLayer?
body: <p>I have already tried this solution <a href="https://stackoverflow.com/questions/3816527/cgimage-or-uiimage-from-a-calayer">CGImage (or UIImage) from a CALayer</a> </p>
  
  <p>However I do not get anything. </p>
  
  <p>Like the question says, I am trying to get an UIImage from the preview layer of the camera. I know I can either capture a still image or use the outputsamplebuffer but my session quality video is set to photo so either of these 2 aproaches are slow and will give me a big image. </p>
  
  <p>So what I thought could work is to get the image directly from the preview layer, since this has exactly the size I need and the operations have already been made on it. I just dont know how to get this layer to draw into my context so that I can get it as an UIImage.</p>
  
  <p>Perhaps another solution would be to use OpenGL to get this layer directly as a texture?</p>
  
  <p>Any help will be appreciated, thanks.</p>