【问题标题】:Exception when reusing CIDetector重用 CIDetector 时的异常
【发布时间】:2023-03-27 21:14:01
【问题描述】:

在尝试使用 CIDetector 检测人脸时减少计算时间时,我尝试按照 Apple 的建议重用单个检测器实例进行多个人脸检测:

这个类可以维护许多会影响性能的状态变量。因此,为了获得最佳性能,请重用 CIDetector 实例而不是创建新实例。

在我开始处理数千张照片之前,一切都很好。现在,我不时收到一个随机异常EXC_BAD_ACCESS。当我不重复使用检测器而是每次都实例化一个新检测器时,不会发生这种情况。

一些相关代码sn-ps:

@property (retain, nonatomic) CIDetector* faceDetector;

- (void)initialVals {
    NSDictionary *opts_context = @{kCIContextUseSoftwareRenderer: @NO};
    self.context = [CIContext contextWithOptions:opts_context];
    NSDictionary *opts = @{ CIDetectorAccuracy: CIDetectorAccuracyHigh,
                        CIDetectorTracking: @YES,
                        CIDetectorMinFeatureSize: @0.15
                      };
self.faceDetector = [CIDetector detectorOfType:CIDetectorTypeFace context:self.context options:opts];

}

我不确定,但这个问题可能与CIDetector isn't releasing memory 有关。

【问题讨论】:

    标签: ios objective-c image-processing ciimage


    【解决方案1】:

    问题已解决,至少部分是通过在创建检测器时删除标志 CIDetectorTracking: @YES

    它在影响功能的同时消除了崩溃。提交了官方错误报告。

    【讨论】:

      猜你喜欢
      • 2012-05-31
      • 2012-08-25
      • 1970-01-01
      • 2021-05-16
      • 1970-01-01
      • 1970-01-01
      • 2012-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多