我们正在尝试将 iOS Affdex SDK 与桥接头(在 Swift 中)结合使用。您能否帮助我们如何进行此过程。还有我们如何基于 SDK 显示表情符号(使用 Swift)。
最佳答案
这里有一些链接可以帮助您使用 Objective-C 到 Swift 的命名约定:
我附上了一个简单的 View Controller 类,它展示了如何在 Swift 中使用我们的 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
}
}
关于ios - 如何在 Swift 中使用 Affdex SDK?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36649238/