captureOutput function isn't called using setSampleBufferDelegate

后端 未结 6 1960
臣服心动
臣服心动 2021-02-19 03:57

I\'m starting to develop an iOS app and this is my first SO post. I\'m trying to implement a UI view which can show the preview video of the rear camera and process the captured

6条回答
  •  情深已故
    2021-02-19 04:41

    I have finally managed to find the cause of the issue. You need to make sure to use the correct function signature for the captureOutput function for the Swift 3 syntax.

    func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)
    

    NOT

    func captureOutput(_ output: AVCaptureOutput, didOutputSampleBuffer sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)
    

    I was using older version of the Swift syntax and the compiler did not warn me of the issue! After correcting the function signatures, the captureOutput function gets called beautifully:-)

提交回复
热议问题