ios - 什么时候发布 AVCaptureDeviceSubjectAreaDidChangeNotification?

标签 ios avfoundation avcapturedevice

在 Apple 的示例代码“AVCam”中,AVCaptureDeviceSubjectAreaDidChangeNotification 被添加到 NSNotificationCenter,但它的回调“subjectAreaDidChange”从未在我的测试中被调用。请问系统什么时候会发出这个通知?

通过以下代码添加:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(subjectAreaDidChange:)
                                             name:AVCaptureDeviceSubjectAreaDidChangeNotification
                                           object:[[self videoDeviceInput] device]];

而AVFoundation的头文件AVCaptureDevice.h如下:

@constant  AVCaptureDeviceSubjectAreaDidChangeNotification
@abstract
   Posted when the instance of AVCaptureDevice has detected a substantial change to the 
   video subject area.
@discussion
   Clients may observe the AVCaptureDeviceSubjectAreaDidChangeNotification to know when an
   instance of AVCaptureDevice has detected a substantial change to the video subject area.
   This notification is only sent if you first set subjectAreaChangeMonitoringEnabled to
   YES.

这就是我的全部问题。非常感谢。

最佳答案

你设置了吗

[[self videoDeviceInput] device].subjectAreaChangeMonitoringEnabled = YES;

关于ios - 什么时候发布 AVCaptureDeviceSubjectAreaDidChangeNotification?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32582972/

相关文章:

ios - 无法使用 AVCaptureSession 获得任何视频预览

ios - WKwebview 没有正确加载?

android - 如何在 React-Native 中只获得数字键盘?

ios - 通过 AVCaptureMovieFileOutput 和 AVMutableDataItems 在 QuickTime 文件中存储任意元数据

avfoundation - 是否可以在 AVMutableComposition 上同时使用 CIFilter 和 GPUImage 过滤器?

ios - 记录裁剪视频方形长宽比 AVCaptureSession

ios - SpeechKit 转录音频文件

swift - 改进 Swift 中的条码扫描器

ios - 在带有用户键入值的文本字段中添加默认文本

ios - 如何在我们的应用程序中检查 root 的 iOS/iPadOS,例如最近的 checkra1n 漏洞?