【问题标题】:CoreImage CIFeature for detecting face emotions用于检测面部情绪的 CoreImage CIFeature
【发布时间】:2017-03-31 06:54:55
【问题描述】:

我正在尝试使用 CoreImage CIFeature 来检测面部情绪,因为它们是本机 API。我创建了一个示例视图控制器项目并更新了相关代码。当我启动这个 iOS 应用程序时,它会打开相机。当我抬起相机并表现出微笑的情绪时,下面的示例代码检测良好。 我还需要找到其他情绪,例如惊喜、悲伤和愤怒的情绪。我知道 CoreImage CIFeature 没有针对这些其他情绪的直接 API。但是,是否可以通过 iOS 程序尝试操纵可用的 API(例如 hasSmile、leftEyeClosed、rightEyeClosed 等)来检测其他情绪,例如惊喜、悲伤和愤怒?

任何人都可以使用此 API、场景并解决此问题,请提出建议并分享您的想法。

func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!) {

    let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
    let opaqueBuffer = Unmanaged<CVImageBuffer>.passUnretained(imageBuffer!).toOpaque()
    let pixelBuffer = Unmanaged<CVPixelBuffer>.fromOpaque(opaqueBuffer).takeUnretainedValue()
    let sourceImage = CIImage(cvPixelBuffer: pixelBuffer, options: nil)
    options = [CIDetectorSmile : true as AnyObject, CIDetectorEyeBlink: true as AnyObject, CIDetectorImageOrientation : 6 as AnyObject]

    let features = self.faceDetector!.features(in: sourceImage, options: options)

    for feature in features as! [CIFaceFeature] {

        if (feature.hasSmile) {

            DispatchQueue.main.async {
                self.updateSmileEmotion()
            }
        }    
        else {
            DispatchQueue.main.async {
                self.resetEmotionLabel()
            }
        }                     
    }

func updateSmileEmotion () {
    self.emtionLabel.text = " "
    self.emtionLabel.text = "HAPPY"
}
func resetEmotionLabel () {
    self.emtionLabel.text = " "
}

【问题讨论】:

  • 你有没有找到解决你问题的方法,请告诉我我也有要求

标签: ios swift core-image


【解决方案1】:

有多种库可以对图像进行情感分析,其中大多数依赖于机器学习。仅通过查看 CIFeature 为您提供的内容,您不太可能获得相同类型的结果,因为即使与其他面部识别库相比,它也非常有限。见Google Cloud VisonIBM Watson Cloud iOS SDKMicrosoft Cognitive Services

【讨论】:

  • 感谢您的建议。我正在查看是否有任何完全开源的可用源代码,可以阅读和修改更多内容。
猜你喜欢
  • 1970-01-01
  • 2017-03-24
  • 2015-03-12
  • 2017-04-15
  • 1970-01-01
  • 2012-06-08
  • 2013-03-23
  • 2022-10-15
  • 1970-01-01
相关资源
最近更新 更多