是否有人知道如何使用CIdetector检测IOS 8和IOS 7中的人脸检测。我正面临着检测脸部的问题。 我已经在iPhone 6 plus,iPhone 5s和iPhone 4s等设备上进行了测试。
http://maniacdev.com/2011/11/tutorial-easy-face-detection-with-core-image-in-ios-5/
所有上述链接代码都经过测试但结果相同..请帮帮我
`CIImage * image = [CIImage imageWithCGImage:facePicture.image.CGImage]; CIContext * context = [CIContext contextWithOptions:nil]; // 1 NSDictionary * opts = @ {CIDetectorAccuracy:CIDetectorAccuracyHigh}; // 2 CIDetector * detector = [CIDetector detectorOfType:CIDetectorTypeFace 背景:背景 选项:选择采用]; // 3
if([[image properties] valueForKey:(NSString *)kCGImagePropertyOrientation] == nil)
{
opts = @{CIDetectorImageOrientation : [NSNumber numberWithInt:1]};
}
else
{
opts = @{CIDetectorImageOrientation : [[image properties] valueForKey:(NSString *)kCGImagePropertyOrientation]};
}
NSArray * features = [detector featuresInImage:image options:opts];`
提前致谢
答案 0 :(得分:1)
您可以将此CI subclass用于面部检测器。此类不依赖于图像大小输入来检测面部,并且它具有灵活的大小输出。
答案 1 :(得分:0)
CIDetector *smileDetector = [CIDetector detectorOfType:CIDetectorTypeFace
context:context
options:@{CIDetectorTracking: @YES,
CIDetectorAccuracy: CIDetectorAccuracyLow}];
NSArray *features = [smileDetector featuresInImage:image options:@{CIDetectorSmile: @YES}];
答案 2 :(得分:0)
见下面的代码..
CIImage *image = [CIImage imageWithCGImage:self.imageView.image.CGImage];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil options:@{CIDetectorAccuracy:CIDetectorAccuracyHigh}];
NSDictionary *options = @{ CIDetectorSmile: @(YES) };
NSArray *features = [detector featuresInImage:image options:options];
for(CIFaceFeature *feature in features) {
NSLog(@"Smile %@", feature.hasSmile ? @"YES" : @"NO");
}