Как использовать Affdex SDK в Swift?

Мы пытаемся использовать iOS Affdex SDK с мостовым заголовком (в Swift). Можете ли вы помочь нам, как пройти этот процесс. Также, как мы можем отобразить эмодзи на основе SDK (agin используя Swift).

1 ответ

Решение

Вот несколько ссылок, которые помогут вам с соглашениями об именах от Objective C до Swift:

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

Я приложил простой класс контроллера представления, который показывает, как использовать наш SDK в Swift. Надеюсь, это поможет вам.

    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
        }
    }
Другие вопросы по тегам