- - (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;
- }
使用CoreImage进行人脸识别
最新推荐文章于 2023-12-15 11:36:24 发布
本文介绍了一种使用Core Image框架中的CIDetector类来检测图片中是否有人脸的方法。通过创建CIImage对象并利用CIDetector进行人脸检测,可以判断图片中是否存在左眼、右眼及嘴巴等面部特征。
3096

被折叠的 条评论
为什么被折叠?



