Trueface iOS SDK

Getting started with Trueface iOS's SDK

version 0.4 - supports for arm64 and x86_64 --- also supports Xamarin amd64 / x86_64

License

To obtain a License key, please contact our sales team and provide your Bundle Identifier.

Configuration

Download Trueface iOS's SDK, extract zip file, drag and drop libtrueface-arm64.a and include folder to your project.

Add CoreMedia.framework, CoreVideo.framework, AssitsLibrary.framework and AVFoundation.framework to linked Frameworks and libraries

Swift Note: you need to link libc++.tdb

Breaking chances: as of 0.3 to improve stability of image encoding and performance, we have changed UIImage to file path.

Breaking chances: as of 0.3.1 to improve interoperability with C# and swift, we have introduced minor breaking changes of types.

Quick Example

In additional of getFaces and getFeatures, there is companion methods getFacesOfUIImage and getFeaturesOfUIImage that accepts UIImage instead of file path.

#import "include/trueface/face_recognizer.h"

FaceRecognizer *fr = [[FaceRecognizer alloc] init];
[fr setLicense:@"..."];
bool isLicensed = [fr isLicensed];
NSLog(@"res isLicensed  => %d", isLicensed);
    
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"images" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];

NSString *person1 = [bundle pathForResource:@"person1" ofType:@"jpg"];
NSSet *faces = [fr getFaces:person1 :true];
FRFbox *fbox = faces.allObjects.firstObject;
NSArray* f1 = [fr getFeatures:person1 :fbox];

/** or using *OfUIImage **/
UIImage *ui_image1 = [UIImage imageWithContentsOfFile:person1];
faces = [fr getFacesOfUIImage:*ui_image1 :true];
fbox = faces.allObjects.firstObject;
f1 = [fr getFeaturesOfUIImage:*ui_image1 :fbox];
/** - **/
    
NSString *person2 = [bundle pathForResource:@"person2" ofType:@"jpg"];
faces = [fr getFaces:person2 :true];
fbox = faces.allObjects.firstObject;
NSArray* f2 = [fr getFeatures:person2 :fbox];
NSLog(@"f2 => %@", [fr getFeaturesAsCSV:f2]);
    
double sim = [fr getSimilarity:f1 :f2];
NSLog(@"sim => %f", sim);

#-- or csv string from database --#

NSArray* f1 = [fr CSVAsFeatures:@"-0.431, 0.192, -0.618, -0.568, -0.092, 0.331, -2.508, 0.521, -1.345, -0.133, 0.6, -0.642, 1.025, -0.384, 0.809, 0.557, -0.364, -0.36, -1.564, 0.367, -0.381, -0.771, 0.711, 0.024, -0.089, -0.354, 0.304, -0.488, -0.177, -1.48, 0.719, -0.829, 1.068, -0.876, -1.308, 0.413, 1.006, 0.613, -0.518, 0.139, -0.002, 0.375, 0.559, -0.792, -0.544, 1.181, 0.981, -0.052, 0.43, -0.533, -0.801, 0.019, -0.243, -0.632, -0.366, 0.175, -1.379, -0.412, -1.805, 0.59, -0.039, 0.305, 0.799, -2.55, 0.031, 0.324, -0.762, 0.802, -0.441, -0.113, -0.187, 2.093, -0.609, 0.757, 0.37, -0.434, -0.288, 0.096, 0.305, 0.064, 0.234, 0.825, 1.689, -0.567, 0.88, -0.03, 0.131, 0.353, 0.211, -0.037, -0.585, -0.941, 0.833, -0.333, 1.397, 0.861, -0.755, 0.442, -0.37, -1.875, -0.266, -0.434, -1.047, -2.085, 0.177, 0.08, -0.789, 0.122, 1.348, -1.305, -0.105, 0.49, 0.1, 0.134, -0.308, -0.994, -0.392, -0.031, -1.371, -0.717, 0.369, 0.325, 0.316, -0.5, 0.55, -0.435, -0.869, 0.068"];

NSArray* f2 = [fr CSVAsFeatures:@"-1.192, 1.526, 0.368, -0.092, -0.206, 1.6, 0.566, 0.418, -3.191, -0.749, 0.003, -1.426, 0.588, 1.59, 0.245, 0.168, 1.29, -0.845, -0.948, -0.695, -1.259, -1.328, 0.964, 0.263, -0.515, -0.224, 0.644, -0.496, 0.714, 0.63, -0.199, -1.168, 0.729, 0.452, -0.176, 0.958, 1.326, 1.478, 0.183, -0.323, -0.633, -0.049, 0.843, -0.658, -0.579, 1.701, -0.542, -0.414, 0.05, 0.194, -0.404, -0.265, -0.814, -0.182, -0.797, -0.255, -1.029, 0.38, -0.887, 0.016, 0.738, 1.02, -0.028, 0.921, 1.418, -0.554, -1.177, 0.234, 0.439, -0.56, 0.717, 3.168, -0.348, 0.505, 0.417, -1.144, -0.611, -0.164, 0.495, 0.556, -0.064, 0.395, 1.841, 0.942, 1.951, 0.41, -0.392, 1.066, -0.415, -0.874, -0.461, 0.334, 0.333, 1.477, -0.324, 1.172, -0.111, 0.043, 0.386, -0.653, 0.019, 0.776, -0.254, -0.817, 0.241, 0.057, 0.86, 0.451, -0.074, -0.368, -0.789, 0.908, 1.324, 0.53, -0.076, -0.922, -0.862, -0.271, -0.373, -1.264, 0.264, -0.483, -0.544, -1.424, 0.102, 1.645, 0.786, 0.745"];

double sim = [fr getSimilarity:f1 :f2];
NSLog(@"sim  => %f", sim);

API

FaceRecognizer class

- (id)init;
- (bool)setLicense:(NSString *)token;
- (bool)isLicensed;

- (NSArray *)CSVAsFeatures:(NSString *)csv;
- (double)getSimilarity:(NSArray *)f1
                       :(NSArray *)f2;

- (NSSet *)getFacesOfUIImage:(UIImage *)image
                            :(bool)first;

- (NSSet *)getFaces:(NSString *)image
                   :(bool)first;

- (NSArray *)getFeaturesOfUIImage:(UIImage *)image
                                 :(FRFbox *)fbox;

- (NSArray *)getFeatures:(NSString *)image
                      :(FRFbox *)fbox;
- (NSString*)getFeaturesAsCSV:(NSArray *)features;

FRFbox object

@property(assign) int x1;
@property(assign) int y1;
@property(assign) int x2;
@property(assign) int y2;

Trueface iOS SDK


Getting started with Trueface iOS's SDK

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.