YoonitFacefy 1.0.7

YoonitFacefy 1.0.7

Luigui DelyerHaroldo Teruya 维护。



  • Haroldo Teruya 和 Luigui Delyer 贡献

iOS Yoonit Facefy

Google MLKit 集成

人脸检测

人脸轮廓

人脸表情

人脸动作

赞助商

白金级
成为赞助商!

目录

安装

将以下行添加到 Podfile 文件中

pod 'YoonitFacefy'

并在您项目的根目录下运行

pod install

使用方法

这是对FacefyYoonit的基本用法,您可以自由使用示例。

import YoonitFacefy

...

let image = UIImage(contentsOfFile: "image path")
let facefy: Facefy = Facefy()

self.facefy.detect(image!) { faceDetected in                                      
    if let faceDetected: FaceDetected = faceDetected {
        
        if let leftEyeOpenProbability = faceDetected.leftEyeOpenProbability {
            print(String(format: "%.2f", leftEyeOpenProbability))
        }
        if let rightEyeOpenProbability = faceDetected.rightEyeOpenProbability {
            print(String(format: "%.2f", rightEyeOpenProbability))
        }
        if let smilingProbability = faceDetected.smilingProbability {
            print(String(format: "%.2f", faceDetected.smilingProbability))
        }
        if let hasHeadEulerAngleX = faceDetected.hasHeadEulerAngleX {
            print(String(format: "%.2f", hasHeadEulerAngleX))
        }
        if let hasHeadEulerAngleY = faceDetected.hasHeadEulerAngleY {
            print(String(format: "%.2f", hasHeadEulerAngleY))
        }                
        if let hasHeadEulerAngleZ = faceDetected.hasHeadEulerAngleZ {
            print(String(format: "%.2f", hasHeadEulerAngleZ))
        }
                    
        if let cgImage = image?.cgImage {                                                        
            
            // Crop the face image from the camera frame.
            let faceImage = UIImage(
                cgImage: cgImage.cropping(to: faceDetected.boundingBox)!
            ).withHorizontallyFlippedOrientation()
        }
    }
} onError: { message in
    print(message)
}

API

方法

函数 参数 返回类型 描述
detect image: UIImage, onSuccess: @escaping (FaceDetected?) -> Void, onError: @escaping (String) -> Void void 从图像中检测人脸并使用闭包返回结果到FaceDetected

FaceDetected

属性 类型 描述
boundingBox CGRect 与图像输入相关的人脸边界框。
leftEyeOpenProbability Float? 左眼开启概率。
rightEyeOpenProbability Float? 右眼开启概率。
smilingProbability Float? 微笑概率。
headEulerAngleX Float? 表示垂直头方向的度数角度。见头部运动
headEulerAngleY Float? 表示水平头方向的度数角度。见头部运动
headEulerAngleZ Float? 表示倾斜头方向的度数角度。见头部运动
contours [CGPoint] 表示检测到的人脸形状的点列表。

头部运动

这里解释上面的gif动画以及如何得到“结果”。每个“运动”(垂直、水平和平移)是一个状态,基于表示头方向的度数角度;

头部方向 属性 v < -36° -36° < v < -12° -12° < v < 12° 12° < v < 36° 36° < v
垂直 headEulerAngleX 超级下 前侧 超级上
水平 headEulerAngleY 超级左 前侧 超级右
倾斜 headEulerAngleZ 超级右 前侧 超级左

参与进来并让它变得更好

克隆存储库,修改您想要的内容并发送PR。对于提交信息,我们使用常规提交

欢迎贡献!


Yoonit团队