iOS面部检测失败,面部不完整

时间:2015-01-30 03:50:24

标签: ios objective-c face-detection core-image face-recognition

我使用Core Image进行面部检测,如下所示:

 CIImage* image = [CIImage imageWithCGImage:aImage.CGImage];

//create Facedetector
NSDictionary  *opts = [NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh
                                                  forKey:CIDetectorAccuracy];
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
                                          context:nil
                                          options:opts];

//Pull out the features of the face and loop through them
NSArray* features = [detector featuresInImage:image];

但是我发现当我使用完全脸部的图片时,它可以正确地检测到脸部,但是当我使用不完整的脸部时,它会失败,就像下面的快照一样: enter image description here

我的代码出了什么问题,CIDetector是否只适用于完全正面?

[更新] here是我的代码,我只能检测到左边的

1 个答案:

答案 0 :(得分:0)

如果它不是一张满脸的话有时候就无法检测到它,我不认为你可以做任何事情。

但您可以为图像添加白色边框,然后可以检测到它,请参见下图,或者您可以深入了解openCV并查看openCV库是否可以检测到它。你帖子中的图片有两个面,如果你下载它并尝试它你会发现,主要是因为它在右面有一个白色边框,与背景颜色相同。

face detection result

我所做的是将imageView添加为容器视图的子视图,该帧略大于imageView的帧。然后我做了容器视图的快照。图片反映了快照图像的检测结果。