iOS人脸检测问题 [英] iOS Face Detection Issue

查看:204
本文介绍了iOS人脸检测问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在iOS 5中使用CoreImage的人脸检测,但它没有检测到任何东西。我试图使用此代码检测刚刚被相机捕获的图像中的面部:

I am trying to use CoreImage's face detection in iOS 5 but it is not detecting anything. I am trying to detect faces in an image that was just captured by the camera using this code:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    NSDictionary *detectorOptions = [[NSDictionary alloc] initWithObjectsAndKeys:CIDetectorAccuracyHigh, CIDetectorAccuracy, nil];     
    CIDetector *faceDetector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:detectorOptions];
    NSArray *features = [faceDetector featuresInImage:image.CIImage];
    NSLog(@"Features = %@", features);
    [self dismissModalViewControllerAnimated:YES];
}

这个编译并运行正常但是无论是什么,feature数组总是空的在图像...任何想法?

This compiles and runs fine but it the features array is always empty regardless of what's in the image... Any ideas?

推荐答案

我不能直接回复你的@ 14:52评论Vic320,但是我一直在玩前置摄像头进行人脸检测 - 因为我无法让前置摄像头拿起我的脸,所以我四处转圈......

I can't reply to your @14:52 comment directly Vic320, but I've been playing with the front camera for face detection - I went round and round in circles since I couldn't get the front camera to pick up my face at all...

原来它对旋转非常敏感 - 我注意到当我的iPad2处于纵向状态时(正如您在使用前置摄像头时所期望的那样),我的识别准确率低于10%。一时兴起,将它转向侧面,并使用前置摄像头获得100%的识别。

Turns out it's very sensitive to rotation - I noticed that when holding my iPad2 in portrait (as you'd expect while using the front camera) I was getting less than 10% recognition accuracy. On a whim, turned it sideways and was getting 100% recognition with the front camera.

如果你使用前置摄像头总是纵向的简单修复就是添加这个小片段:

Simple fix for this if you're using the front camera always in portrait is to add this little snippet:

NSDictionary* imageOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:6] forKey:CIDetectorImageOrientation];
NSArray* features = [detector featuresInImage:image options:imageOptions];

那里的6强迫探测器以纵向模式运行。 Apple的 SquareCam 示例包含大量实用工具方法如果你需要它来动态地确定你的方向,找出你所处的方向。

That 6 in there forces the detector to operate in portrait mode. Apple's SquareCam Sample has a whole bunch of utility methods to figure out what orientation you're in if you need it to dynamically figure out your orientation.

这篇关于iOS人脸检测问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆