2016-11-16 9 views
0

CoreImage CIFeature를 네이티브 API처럼 얼굴 감정을 감지하려고합니다. 샘플보기 컨트롤러 프로젝트를 만들고 관련 코드를 업데이트했습니다. 이 iOS 응용 프로그램을 실행하면 카메라가 열립니다. 카메라를보고 웃음 감정을 표시 할 때 아래 샘플 코드는 괜찮습니다. 놀람, 슬픔, 화난 감정과 같은 다른 감정을 찾아야합니다. CoreImage CIFeature에는 이러한 다른 감정에 대한 직접 API가 없다는 것을 알고 있습니다. 그러나 iOS 프로그램을 통해 놀람, 슬픔, 분노와 같은 다른 감정을 감지하기 위해 hasSmile, leftEyeClosed, rightEyeClosed 등과 같은 사용 가능한 API를 조작 할 수 있습니까?CoreImage 얼굴 감정을 검출하는 CIFeature

누구나이 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 = " " 
} 

답변

0

이미지에 대한 정서 분석을 할 수있는 다양한 라이브러리가 있으며, 대부분은 기계 학습에 의존합니다. CIFeature가 당신에게주는 것을 보아서 같은 종류의 결과를 얻지는 않을 것 같지만 다른 안면 인식 라이브러리와 비교해도 꽤 제한적입니다. Google Cloud Vison, IBM Watson Cloud iOS SDK, Microsoft Cognitive Services

+0

제안 해 주셔서 감사합니다. 사용할 수있는 완전히 공개 된 소스를 찾고 있다면 더 많이 읽고 수정할 수 있습니다. – Stella

관련 문제