2016-04-15 35 views
1

我們正在嘗試使用iOS Affdex SDK和橋接頭(在Swift中)。你能幫助我們怎麼去做這個過程。另外,我們如何顯示基於SDK的emojis(使用Swift的agin)。如何在Swift中使用Affdex SDK?

回答

4

這裏有一些鏈接,可以幫助您與Objective-C的斯威夫特命名約定:

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html

我們已經附上一個簡單的視圖控制器類,它展示瞭如何使用我們的斯威夫特SDK。希望這會幫助你。

class ViewController: UIViewController, AFDXDetectorDelegate { 

    var detector : AFDXDetector? = nil 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     // create the detector 
     detector = AFDXDetector(delegate:self, usingCamera:AFDX_CAMERA_FRONT, maximumFaces:1) 
     detector?.setDetectEmojis(true) 
     detector!.start() 
    } 

    func detectorDidStartDetectingFace(face : AFDXFace) { 
     // handle new face 
    } 

    func detectorDidStopDetectingFace(face : AFDXFace) { 
     // handle loss of existing face 
    } 

    func detector(detector : AFDXDetector, hasResults : NSMutableDictionary?, forImage : UIImage, atTime : NSTimeInterval) { 
     // handle processed and unprocessed images here 
     if hasResults != nil { 
      // handle processed image in this block of code 

      // enumrate the dictionary of faces 
      for (_, face) in hasResults! { 
       // for each face, get the rage score and print it 
       let emoji : AFDXEmoji = face.emojis 
       let rageScore = emoji.rage 
       print(rageScore) 
      }     
     } else { 
      // handle unprocessed image in this block of code 
     } 
    } 
+0

'public init!(delegate:AFDXDetectorDelegate!,using camera:AFDXCameraType,maximumFaces:UInt)'從Swift 3開始是不贊同的,任何替代方案? –

相關問題