2016-04-15 47 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开始是不赞同的,任何替代方案? –