From 9b05c7424b0c32453a6c169893527b79579731f3 Mon Sep 17 00:00:00 2001 From: Daniel Hu Date: Wed, 14 Sep 2016 13:51:49 +0800 Subject: [PATCH] only process for face feature --- bf/bf/BetterFaceClass/UIImageView+BetterFace.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bf/bf/BetterFaceClass/UIImageView+BetterFace.m b/bf/bf/BetterFaceClass/UIImageView+BetterFace.m index 2b4e8ca..ef509b4 100644 --- a/bf/bf/BetterFaceClass/UIImageView+BetterFace.m +++ b/bf/bf/BetterFaceClass/UIImageView+BetterFace.m @@ -101,7 +101,8 @@ - (void)faceDetect:(UIImage *)aImage NSArray* features = [detector featuresInImage:image]; - if ([features count] == 0) { + NSInteger faceFeatureCount = [self countOfFaceFeatureWithFeatures:features]; + if (faceFeatureCount == 0) { BFLog(@"no faces"); dispatch_async(dispatch_get_main_queue(), ^{ [[self imageLayer] removeFromSuperlayer]; @@ -115,6 +116,16 @@ - (void)faceDetect:(UIImage *)aImage }); } +- (NSUInteger)countOfFaceFeatureWithFeatures:(NSArray *)features { + NSUInteger count = 0; + for (CIFeature *feature in features) { + if ([feature.type isEqualToString:CIFeatureTypeFace]) { + count++; + } + } + return count; +} + -(void)markAfterFaceDetect:(NSArray *)features size:(CGSize)size{ CGRect fixedRect = CGRectMake(MAXFLOAT, MAXFLOAT, 0, 0); CGFloat rightBorder = 0, bottomBorder = 0;