2012-07-23 92 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