iOS Local Detector


This instruction shows how to use Face++ offline iOS Face Detection Application. Notice: Please run the program in actual device(armv6/armv7), we do not support simulator for the moment.

Setting Up the Environment

Please visit the Developers page and choose one of your application (or create one). In the application management page, download the IOS offline detector. Unzip the file and you will see,
  • FaceppLocalDetectorSDK: offline iOS detector,
    • FaceppLocalDetectorSDK\FaceppDetection+LocalResultUploader.h: API definitoin of the offline detector and online API.
    • FaceppLocalDetectorSDK\FaceppLocalDetector.h: Headers of the offline detector.
    • FaceppLocalDetectorSDK\libFaceppLocalDetector.a: Binaries of the offline detector.
  • FaceppSDK: online Face++ API SDK.

How to Use

Now you can run the offline iOS Face Detection Application by executing the following steps in order, 1. Create a new iOS project in Xcode 2. Add three files of offline SDK and Face++ iOS SDK to the project. Shown as below.


Now, you can see libFaceppLocalDetector.a under Build Phases.


3. Modify the C++ Language Dialect to the default compiler in Building Setting. Shown as follow,


4. Because the Face++ library is writtern in C++, every method which imports Face++ offline detector function should be renamed from .m to .mm (otherwise there will be compiling issues), including the auto-generated AppDelegate.m and main.m. Shown as follow,


5. Create a new FaceppLocalDetector in your program to run the detector. Please notice that the API_Key used for initialization should be the same as the API_Key used for the offline iOS Detector. There is an example as follow,
  1. Initialization.
    NSDictionary *options = [NSDictionary dictionaryWithObjects:[
            NSArray arrayWithObjects:[NSNumber numberWithBool:YES],
            [NSNumber numberWithInt:20],
            FaceppDetectorAccuracyHigh, nil]
            NSArray arrayWithObjects:FaceppDetectorTracking,
            FaceppDetectorAccuracy, nil]];
    FaceppLocalDetector *detector = [
        FaceppLocalDetector detectorOfOptions: options andAPIKey:@"xx"];
  1. Detect and output the results.
    FaceppLocalResult *result = [
        detector detectWithImage:[UIImage imageNamed:@"2007011321.jpg"]];
    NSLog(@"count = %d", result.faces.count);
    for (size_t i=0; i < result.faces.count; i++) {
        FaceppLocalFace *face = [result.faces objectAtIndex:i];
        NSLog(@"    rect = %@, trackingId = %d",
6. You can combine the offline iOS detector with the online API to get access to more functions. More specifically, by adding new method to FaceppDetection in the offline detector, you can upload the detection results (only the face part will be uploaded, so the uploading data size will be reduced) to get the face_id and more online operations. Shown as follow,
// Test Sync Local Result to Server
[FaceppAPI initWithApiKey:@"YOUR_API_KEY" andApiSecret:@"YOUR_API_SECRET"
[FaceppAPI setDebugMode:YES];
[[FaceppAPI detection] uploadLocalResult:result