2017-11-17 1 views
1

미소의 확률을 실시간으로 감지하려고합니다. Google 모바일 비젼을 사용했지만 앱이 옵션 매개 변수로 인해 충돌이 발생했습니다. GMVDetector에서 전달합니다. 때문에 캐치되지 않는 예외 'NSInvalidArgumentException'응용 프로그램 종료, 이유는실시간 프레임 캡처에서 GoogleMobileVision을 사용하는 방법은 무엇인가요?

: '- [_ SwiftValue있는 intValue]

또한 메모리 문제를주고있다 전무로 내가 옵션을 전달하고 때.

내 코드 :

import UIKit 
import GoogleMobileVision 

class ViewController: UIViewController, FrameExtractorDelegate { 

@IBOutlet weak var lblSmiling: UILabel! 
var frameExtractor: FrameExtractor! 
var faceDetector = GMVDetector() 

@IBOutlet weak var imageView: UIImageView! 

@IBAction func flipButton(_ sender: UIButton) { 
    frameExtractor.flipCamera() 
} 

override func viewDidLoad() { 
    super.viewDidLoad() 
    frameExtractor = FrameExtractor() 
    frameExtractor.delegate = self 
    let options: NSDictionary = [GMVDetectorFaceLandmarkType: GMVDetectorFaceLandmark.all, GMVDetectorFaceClassificationType: GMVDetectorFaceClassification.all, GMVDetectorFaceTrackingEnabled: true] 

    self.faceDetector = GMVDetector(ofType: GMVDetectorTypeFace, options: options as! [AnyHashable : Any]) 
} 

// Getting individual frame image here 
func captured(image: UIImage) { 
    processImage(image: image) 
    imageView.image = image 
} 

func processImage(image: UIImage) { 

    let faces : [GMVFaceFeature] = faceDetector.features(in: image, options: nil) as! [GMVFaceFeature] 

    for face in faces { 

     if face.hasSmilingProbability && face.smilingProbability > 0.4 { 
      lblSmiling.text = String(describing: face.smilingProbability) 
     } 
    } 
} 

}

답변

0

난 당신이 몇 가지 옵션 값을 사용하고있는 생각은, 당신은 작동합니다 후이 코드를 작성해야합니다.

let options: NSDictionary = [GMVDetectorFaceLandmarkType: GMVDetectorFaceLandmark.all.rowValue, GMVDetectorFaceClassificationType: GMVDetectorFaceClassification.all.rowValue, GMVDetectorFaceTrackingEnabled: true] 
관련 문제