因此,我试图实现一个自定义摄像机视图,该视图从视频中获取帧,因此我正在设置捕获会话并设置捕获委托,并使用以下方法:
class Permissions(object):
@staticmethod
def requires(*conditions):
user = user2
def decorator(func):
@wraps(func)
def allower(*args, **kwargs):
if not user.logged_in:
return print('You\'re not logged in, please log in.')
if not all(i(user) for i in conditions):
return print('Not all of the conditions were met.')
return func(*args, **kwargs)
return allower
return decorator
但是当我这样做时,它永远不会被调用,所以我尝试了here接受的答案,并添加了这样的强制展开:
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)
现在它可以正常工作并被正确调用。但是xcode一直给我这个警告
'captureOutput(_:didOutput:from :)'的参数具有与协议'AVCaptureVideoDataOutputSampleBufferDelegate'预期的不同的可选性
替换'!,didOutput sampleBuffer:CMSampleBuffer !,来自连接:AVCaptureConnection!'与',didOutput sampleBuffer:CMSampleBuffer,来自连接:AVCaptureConnection'
当我按下fix时,它只是将其更改回不起作用的方法的第一个版本。有什么原因让我不断收到此警告吗?我可以做些什么来修复它,还是只需要让短绒棉绒忽略它?