简体   繁体   English

iOS可以检测到人脸吗?

[英]iOS detect human face Can I know the face is inverted or normal?

can I get the face is inverted or normal? 我可以使面部倒立或正常吗? I have finish to code for face detection , 我已经完成了面部检测代码,

just like below: 如下所示:

// 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];
        });
    }
}

with apple sample code: https://developer.apple.com/library/ios/samplecode/SquareCam/Introduction/Intro.html 苹果示例代码: https//developer.apple.com/library/ios/samplecode/SquareCam/Introduction/Intro.html

Can I know the face is inverted or normal? 我能知道脸是倒立还是正常?

I have try to get left eye position and right eye position ,mouth position ,but when the face is inverted ,the position return is not right. 我试图获得左眼位置和右眼位置,嘴巴位置,但是当脸部倒置时,位置返回不正确。

The midPoint is the middle point between two eyes. 中点是两只眼睛之间的中点。 when face is upside the position log 当脸朝上时位置日志

leftEyePoistion -------------------{160, 199}
rightEyePosition ------------------{270, 262}
midPoint----------------------------------- {215, 230.5}
mouthEyePostion ---------------------------- {297, 112}

when face is inverted the position log 脸部倒立时的位置记录

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

so I don`t think the position is right for me to make sure the face is upside or not. 所以我认为这个姿势不适合我以确保面部是否朝上。

Yes, you can use Core Image to detect faces. 是的,您可以使用Core Image来检测人脸。 Among the information you get back when a face is detected are the position of the eyes and the position of the mouth, and you can use that to determine orientation. 在检测到脸部时返回的信息包括眼睛的位置和嘴巴的位置,您可以使用这些信息来确定方向。 Read more about it in the Detecting Faces section of the Core Image Programming Guide . 在《 核心图像编程指南》的“ 检测面部”部分中了解有关此内容的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM