2012-07-23 89 views
1

我用下面的代码从图像中检测脸:人脸检测算法是不工作

-(void)markFaces:(UIImageView *)imagePick { 

CIImage* image = [CIImage imageWithCGImage:imagePick.image.CGImage]; 
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace 
              context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]]; 
NSDictionary* imageOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:6] forKey:CIDetectorImageOrientation]; 
NSLog(@"imageOptions %@",imageOptions); 
NSArray* features = [detector featuresInImage:image options:imageOptions]; 

if([features count] > 0) 
{ 
    NSLog(@"Face Found"); 
} 
else 
{ 
    NSLog(@"Face not Found");   
} 
} 

,如果我从横向单击快照这种算法是行不通的模式。为什么?任何帮助,将不胜感激。

由于提前

+1

它用于以纵向倒置模式拍摄的图像(顶部的主页按钮)。您可以尝试通过应用转换来旋转捕捉图像。 – lukya 2012-07-23 07:16:24

+0

看一下它 http://stackoverflow.com/questions/10496724/how-to-develop-a-face-recognition-iphone-app/10497002#10497002 它可以帮助你:) – 2012-07-23 07:18:28

回答

0

我认为这个问题是在这一行:

NSDictionary* imageOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:6] forKey:CIDetectorImageOrientation]; 

你实际上是告诉它寻找肖像取向仅作为你逝去的数量是6

头文件中的文档说明:

//可与 - [ CIDetector featuresInImage:options:]

/*此密钥的值是1到8之间的整数NSNumber,例如在kCGImagePropertyOrientation中找到的那个 。如果存在,则基于该方向检测将被执行 ,但返回特征中的坐标将仍然基于图像的那些坐标。 */

和选项的

enter image description here

这是烦人,featuresInImage:options:没有文档(我现在得提交错误,我已经看到了它)

+0

好吧,谢谢你,我也发现了。 – iYahoo 2012-07-24 06:12:48