gpt4 book ai didi

iphone - iOS 7 CIFeature : CIDetectorEyeBlink doesnt detect closed eyes in image

转载 作者:行者123 更新时间:2023-12-03 19:31:54 29 4
gpt4 key购买 nike

我正在开发一个 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");
}

最佳答案

我遇到了同样的问题,但是在尝试了这个之后 tutorial我意识到我没有添加:CIDetectorImageOrientation选项例如:

NSDictionary *detectorOptions = @{ CIDetectorAccuracy : CIDetectorAccuracyHigh };
CIDetector *faceDetector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:detectorOptions];

NSArray *features = [faceDetector featuresInImage:[CIImage imageWithCGImage:_imageView.image.CGImage]
options:@{ CIDetectorSmile : @YES,
CIDetectorEyeBlink : @YES,
CIDetectorImageOrientation :[NSNumber numberWithInt:ORIENTATION_NUMBER] }];

现在可以顺利运行了;)

关于iphone - iOS 7 CIFeature : CIDetectorEyeBlink doesnt detect closed eyes in image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18918147/

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