我正在按照以下方法对帧进行某种处理
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {}
但是我不想在所有帧中都这样做,比如说我想要1/15或1/10,如何实现此目标?swift是否提供了任何预构建逻辑?
答案 0 :(得分:0)
您可以在类中添加一个计数器,然后在 captureOutput
中增加它func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection){
i += 1
if (i % 15 == 0) //every 15 frames
{
//process your frame
}
}