iOS检测人脸我可以知道脸部是倒置还是正常?

时间:2014-03-17 08:24:57

标签: ios

我可以让脸部倒置或正常吗?我已经完成了人脸检测的编码,

如下所示:

// turn on/off face detection
- (IBAction)toggleFaceDetection:(id)sender
{
    detectFaces = [(UISwitch *)sender isOn];
    [[videoDataOutput connectionWithMediaType:AVMediaTypeVideo] setEnabled:detectFaces];
    if (!detectFaces) {
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            // clear out any squares currently displaying.
            [self drawFaceBoxesForFeatures:[NSArray array] forVideoBox:CGRectZero orientation:UIDeviceOrientationPortrait];
        });
    }
}

使用apple示例代码:https://developer.apple.com/library/ios/samplecode/SquareCam/Introduction/Intro.html

我可以知道脸部是倒置的还是正常的?

我试图获得左眼位置和右眼位置,嘴巴位置,但当脸部倒置时,位置返回不正确。

midPoint是两只眼睛之间的中间点。 当面子上升时 位置记录

leftEyePoistion -------------------{160, 199}
rightEyePosition ------------------{270, 262}
midPoint----------------------------------- {215, 230.5}
mouthEyePostion ---------------------------- {297, 112}
当脸被倒置时

位置记录

leftEyePoistion -------------------{192, 200}
rightEyePosition ------------------{274, 270}
midPoint----------------------------------- {233, 235}
mouthEyePostion ---------------------------- {288, 159}

所以我认为这个位置对我来说是正确的,以确保脸部是否有好处。

1 个答案:

答案 0 :(得分:0)

是的,您可以使用Core Image来检测面部。在检测到脸部时,您获得的信息包括眼睛的位置和嘴巴的位置,您可以使用它来确定方向。在核心图像编程指南Detecting Faces部分中了解更多相关信息。