【问题标题】:iOS detect human face Can I know the face is inverted or normal?iOS检测人脸我能知道人脸是倒置的还是正常的?
【发布时间】:2014-03-18 16:39:06
【问题描述】:

我可以把脸倒过来或正常吗?我已经完成了人脸检测的代码,

如下:

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

附苹果示例代码: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}

所以我认为这个位置不适合我来确定面部是否朝上。

【问题讨论】:

    标签: ios


    【解决方案1】:

    是的,您可以使用 Core Image 来检测人脸。当检测到面部时,您获得的信息包括眼睛的位置和嘴巴的位置,您可以使用它来确定方向。在 Core Image Programming GuideDetecting Faces 部分了解更多信息。

    【讨论】:

    • 我可以把脸倒过来或正常吗?
    • @Roy 如果你已经有了眼睛和嘴巴的位置,就看看它们。如果嘴在眼睛上方,则脸是上下颠倒的。
    • 我是这么想的,但是我得到的位置不对,不管是倒立的还是正常的,眼睛的位置总是在嘴巴上方,所以我拿不到脸方向。
    • @Roy 我也有同样的问题。有什么解决办法吗?
    猜你喜欢
    • 2019-11-18
    • 2013-07-16
    • 2021-08-26
    • 2016-06-02
    • 2018-06-19
    • 2013-04-14
    • 1970-01-01
    • 2017-01-18
    • 2013-09-24
    相关资源
    最近更新 更多