我正在开发一个 iPhone 应用程序,我在其中尝试实施 CIDetectorEyeBlink 以检查图像中的人是否已经闭上眼睛。但是 leftEyeClosed 和 rightEyeClosed 属性总是返回 0/NO。
我粘贴了一些我的代码来实现。
CIImage* image = [CIImage imageWithCGImage:originalImage.CGImage];
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], CIDetectorEyeBlink, [NSNumber numberWithBool:YES], CIDetectorSmile, nil];
NSArray* features = [detector featuresInImage:image options:options];
for(CIFaceFeature* faceObject in features)
{
NSLog(@"TEST left eyeblink: %@", faceObject.leftEyeClosed ? @"YES" : @"NO");
NSLog(@"TEST right eyeblink: %@", faceObject.rightEyeClosed ? @"YES" : @"NO");
}