【发布时间】: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