首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >IOS 6人脸检测不起作用

IOS 6人脸检测不起作用
EN

Stack Overflow用户
提问于 2012-10-05 21:07:31
回答 2查看 2.4K关注 0票数 0

我使用了以下代码来检测iOS5的人脸

代码语言:javascript
运行
复制
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中,我需要做哪些更改才能检测到人脸。

我们非常感谢任何形式的帮助。

EN

回答 2

Stack Overflow用户

发布于 2012-10-19 13:05:38

我注意到iOS6的人脸检测不如iOS5的好。尝试选择一组图像。您可能会发现,它在iOS6中可以很好地处理很多图像,但不是所有图像。

我一直在测试同一组图像: 1.运行iOS6的仿真器。2. iPhone 5 (iOS6) 3. iPhone 3GS (iOS5)

与其他两个选项相比,3GS可以检测到更多的人脸。

下面是代码,它在两者上都有效,但在iOS6上就没那么好了:

代码语言:javascript
运行
复制
- (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];
} 

}

票数 1
EN

Stack Overflow用户

发布于 2012-10-05 21:50:32

我希望这对你有帮助。

添加CoreImage.framework

代码语言:javascript
运行
复制
-(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/tutorial-easy-face-detection-with-core-image-in-ios-5/

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12746934

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档