0

次のコードを使用して、IOS 5 の顔を検出しました。

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 で顔を検出するために必要な変更。

どんな種類のヘルプも大歓迎です

4

2 に答える 2

1

iOS6 の顔検出は iOS5 ほど良くないことに気付きました。画像の選択で試してください。iOS6 では多くの画像で問題なく動作することがわかりますが、すべてではありません。

同じイメージ セットを以下でテストしています。 1. iOS6 を実行しているエミュレータ。2. iPhone 5 (iOS6) 3. iPhone 3GS (iOS5)。

3GS は、他の 2 つのオプションよりも多くの顔を検出します。

コードは次のとおりです。両方で動作しますが、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];
} 

}

于 2012-10-19T05:05:37.693 に答える
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)];


}

この2つのリンクも確認してください

http://maniacdev.com/2011/11/tutorial-easy-face-detection-with-core-image-in-ios-5/

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

于 2012-10-05T13:50:32.030 に答える