gpt4 book ai didi

ios - 重用 CIDetector 时出现异常

转载 作者:行者123 更新时间:2023-11-29 02:54:17 25 4
gpt4 key购买 nike

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

This class can maintain many state variables that can impact performance. So for best performance, reuse CIDetector instances instead of creating new ones.

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

一些相关的代码片段:

@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 有关.

最佳答案

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

它消除了崩溃,同时牺牲了功能。提交了正式的错误报告。

关于ios - 重用 CIDetector 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24109232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com