ios - 如何在 Swift 中使用 Affdex SDK?

标签 ios objective-c swift affdex-sdk

我们正在尝试将 iOS Affdex SDK 与桥接头(在 Swift 中)结合使用。您能否帮助我们如何进行此过程。还有我们如何基于 SDK 显示表情符号(使用 Swift)。

最佳答案

这里有一些链接可以帮助您使用 Objective-C 到 Swift 的命名约定:

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

我附上了一个简单的 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/

相关文章:

ios - 为什么有些 ios header 在没有 cdecl 的情况下被翻译成 pascal?

ios - UITableView 仅反弹底部边缘

objective-c - iOS 11 状态栏更改

ios - Swift 3/为什么 snapshotView 的快照在 iPhone 7 Plus 模拟器中显示为空白?

ios - TableView 与 TextView : go to next Textview?

ios - 为 xcode 项目设置默认字体样式、颜色和大小

ios - 如何在 IOS 7 的模拟器中访问保存的照片

iphone - 如何在 xcode 中更改 iPhone/iOS iPod 的字体和重新设计布局

html - 不针对 iPhone 的 css 媒体查询

ios - Swift 的 DispatchQueue 放在哪里