title: AVCaptureVideoPreviewLayer add overlays and capture photo in iOS
body: <p>The initial idea was to start a camera stream via <code>AVCaptureSession</code>, find faces in that raw <code>CMSampleBuffer</code> and then add some images as layers on <code>AVCaptureVideoPreviewLayer</code> and then take a screenshot.</p>
  
  <p>After completing that, found out later that the <code>UIGraphicsGetImageFromCurrentImageContext</code> won't work with <code>AVCaptureVideoPreviewLayer</code>, so taking screenshot would not solve my purpose here.</p>
  
  <p>So I used <code>Metal</code> and <code>MTKView</code> instead to perform some live rendering and the results are good with the combination of CoreImage Filters and Metal. I already know how to detect faces and alter that part of the face using inbuilt CoreImage filters but I can't find a suitable method to add an image on to another image. </p>
  
  <p>How can I blend two images with respect to positioning in the background image? I have CIImage to work with. </p>