I am working on a swift application and I want to take a picture during the video when the camera is not moving or when user focuses on something. i used AVCaptureVideoDataOutputSampleBufferDelegate *captureOutput method which giving me image every time after starting camera. but I want to take only when the camera is not moving or focused.
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
print("didOutput")
guard let hasImage = CMSampleBufferGetImageBuffer(sampleBuffer) else {
print("no image")
return
}
let ciimage : CIImage = CIImage(cvPixelBuffer: hasImage)
DispatchQueue.main.async {
self.liveCamImage = self.convert(cmage: ciimage)
}
}
is there any solution for this