2012-10-05 58 views
0

我用下面的代碼來檢測人臉的IOS 5IOS 6人臉檢測不工作

CIImage *cIImage = [CIImage imageWithCGImage:image.CGImage]; 
      CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]]; 
      NSArray *features = nil; 
      features = [detector featuresInImage:cIImage]; 
      if ([features count] == 0) 
      { 
       NSDictionary* imageOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:6] forKey:CIDetectorImageOrientation]; 
       features = [detector featuresInImage:cIImage options:imageOptions]; 
      } 

有了這個代碼,我能夠發現在iOS 5中的臉,但最近我們已經升級了系統的Xcode 4.4和IOS 6,現在,人臉檢測工作不正常,

我需要什麼樣的改變在IOS檢測面部做6

幫助Anykind高度讚賞

+0

我不認爲這個問題會發生,請將您的樣品code..i將檢查它 – Rajneesh071

+0

我已經實施了我的項目中的代碼,很難發送它 – iYahoo

+0

你可以使你的問題的樣本.... – Rajneesh071

回答

0

我希望這有助於ü...

添加CoreImage.framework

-(void)faceDetector 

{ 

// Load the picture for face detection 

UIImageView* image = [[UIImageView alloc] initWithImage: 

[UIImage imageNamed:@"facedetectionpic.jpg"]]; 

// Draw the face detection image 

[self.window addSubview:image]; 

// Execute the method used to markFaces in background 

[self markFaces:image]; 

} 


-(void)faceDetector 

{ 

// Load the picture for face detection 

    UIImageView* image = [[UIImageView alloc] initWithImage:[UIImage 
imageNamed:@"facedetectionpic.jpg"]]; 


    // Draw the face detection image 
    [self.window addSubview:image]; 

    // Execute the method used to markFaces in background 
    [self performSelectorInBackground:@selector(markFaces:) withObject:image]; 

    // flip image on y-axis to match coordinate system used by core image 
    [image setTransform:CGAffineTransformMakeScale(1, -1)]; 

    // flip the entire window to make everything right side up 
    [self.window setTransform:CGAffineTransformMakeScale(1, -1)]; 


} 

,並檢查這兩個環節也

http://maniacdev.com/2011/11/教程容易用面部檢測與核圖像合IOS-5/

http://i.ndigo.com.br/2012/01/ios-facial-recognition/

1

我注意到iOS6中的人臉檢測不如iOS5中的人臉檢測。 嘗試一系列的圖像。您可能會發現它在iOS6中可以使用很多圖像,但不是全部。

我一直在測試同一組圖像: 1.運行iOS6的模擬器。 2. iPhone 5(iOS6) 3. iPhone 3GS(iOS5)。

3GS檢測到比其他兩個選項更多的面孔。

下面的代碼,它適用於這兩種,但只是沒有以及在iOS6的:

- (void)analyseFaces:(UIImage *)facePicture { 
// Create CI image of the face picture 
CIImage* image = [CIImage imageWithCGImage:facePicture.CGImage]; 

// Create face detector with high accuracy 
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace 
              context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]]; 

// Create array of detected faces 
NSArray* features = [detector featuresInImage:image]; 

// Read through the faces and add each face image to facesFound mutable 
for(CIFaceFeature* faceFeature in features) 
{ 
    CGSize parentSize = facePicture.size; 

    CGRect origRect = faceFeature.bounds; 
    CGRect flipRect = origRect; 
    flipRect.origin.y = parentSize.height - (origRect.origin.y + origRect.size.height); 

    CGImageRef imageRef = CGImageCreateWithImageInRect([facePicture CGImage], flipRect); 
    UIImage *faceImage = [UIImage imageWithCGImage:imageRef]; 
    CGImageRelease(imageRef); 

    if (faceImage) 
     [facesFound addObject:faceImage]; 
} 

}