您的位置:首页 > 其它

使用CoreImage进行人脸识别

2014-12-25 13:48 423 查看

代码

- (BOOL)checkImageHasFace
{
BOOL hasFace = NO;
CIImage *begingImage = [[CIImage alloc] initWithImage:_postImage];
//创建CIDetector对象,options使用NSDictionary设置采用高品质还是低品质,这里使用低品质。
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyLow forKey:CIDetectorAccuracy]];
//返回数组中包含图片脸部特征信息
NSArray *faceFeatures = [detector featuresInImage:begingImage];
for (CIFaceFeature *faceFeature in faceFeatures) {
//左眼位置、右眼位置和嘴的位置
if (faceFeature.hasLeftEyePosition&&faceFeature.hasRightEyePosition&&faceFeature.hasMouthPosition) {
hasFace = YES;
}
}
return hasFace;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: