【问题标题】:CIDetector trackingID never presentCIDetector trackingID 从不存在
【发布时间】:2013-11-27 19:44:47
【问题描述】:

我正在编写 OSX Mavericks 上的一些人脸检测代码,并尝试利用 CIDetector 提供的跨多个静止图像功能的新的(截至 10.8 版)人脸跟踪。

我的基本人脸检测工作正常,如下所示:

- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
       fromConnection:(AVCaptureConnection *)connection {

    CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
    CIImage *image =  [CIImage imageWithCVImageBuffer:imageBuffer];
    CIDetector *faceDetector = [CIDetector detectorOfType:CIDetectorTypeFace
                                                  context:nil
                                                  options:@{ CIDetectorAccuracy : CIDetectorAccuracyHigh,
                                                         CIDetectorTracking : @YES
                                                        }];
    NSArray *features = [faceDetector featuresInImage:image];
    for ( CIFaceFeature *feature in features ) {
        if (feature.hasTrackingID) {
            NSLog(@"tracking id: %@", @(feature.trackingID));
        }
    }
}

功能列表确实已正确填充,但该 trackingID 似乎从未出现。 有没有人在小牛队得到这个工作?它在山狮上以同样的方式失败。

我在这里看到了一个类似的问题 (CIFaceFeature trackingID is always coming same for multiple faces),但我没有在那里学到任何新东西。

对于它的价值,它似乎在 iOS 上运行正常。

【问题讨论】:

    标签: macos cocoa face-detection osx-mavericks core-image


    【解决方案1】:

    我再次查看了这段代码,结果非常明显:我不断地重新初始化 CIDetector,这对性能不利,并且还导致每帧重置其内部跟踪数据。因此,第一次检测到人脸总是第一次为特定 CIDetector 实例检测到人脸。

    此外,CIDetector 在文档中对此提出警告:

    “此类可以维护许多可能影响性能的状态变量。因此,为了获得最佳性能,请重用 CIDetector 实例而不是创建新实例。”,来自https://developer.apple.com/library/mac/documentation/CoreImage/Reference/CIDetector_Ref/Reference/Reference.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-14
      • 2012-05-31
      • 2018-08-20
      • 1970-01-01
      • 2021-05-16
      • 2015-12-23
      • 1970-01-01
      • 2017-03-01
      相关资源
      最近更新 更多