I am using a
VNDetectFaceLandmarksRequest
combined with a
VNSequenceRequestHandler
to process images coming from the
AVCaptureVideoDataOutput
delegate call:
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)
I want to be able to show the face landmarks in realtime, so that the user can see them overlaid over the AVCaptureVideoPreviewLayer.
So, as the AVCaptureVideoDataOutput delegate gets called, I then call:
func perform(_ requests: [VNRequest], on image: CIImage)
The CIImage comes from the CMSampleBuffer the delegate provides.
The problem is that the landmarks lag. As I move my face in front of the camera the landmarks are quite slow to update.
How can I update the landmarks so that they follow the face movement without lagging behind?