The Trueface Developer Hub

Welcome to the Trueface developer hub. You'll find comprehensive guides and documentation to help you start working with Trueface as quickly as possible, as well as support if you get stuck. Let's jump right in!

Trueface SDK for iOS

Getting started with Trueface SDK for iOS

Version 2.3 (SDK 0.3) Beta - supports arm64 and x86_64 — also supports Xamarin amd64 / x86_64

This iOS binding of Trueface SDK is in beta status, subject for further improvement, enhancement and additional of features.

License

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

Configuration

Download extract zip file, drag and drop framework to your project.

  • Make sure to select “Embed & Sign” in “Frameworks, Libraries, and Embedded Content” section
  • You may need to add CoreMedia.framework, CoreVideo.framework, AssitsLibrary.framework and / or AVFoundation.framework to linked Frameworks and libraries
  • You may need to link libc++.tdb if you are using Swift

Quick Example

Initialize the SDK, set and check validity of license

#import <trueface/sdk.h>

TFSDK* sdk = [[TFSDK alloc] init];
NSString* token = @“…”;
bool isLicensed = [sdk setLicense:token];
if (isLicensed) {
	
}

Set Image from UIImage

UIImage *image = [UIImage
                      imageNamed: path
                      inBundle: [NSBundle bundleForClass: [self class]]
                      compatibleWithTraitCollection: nil];
TFErrorCode errorCode = [sdk setImage:image];

Detect objects in image

NSSet* objects = [sdk detectObjects];
for (TFBoundingBox* box in objects) {
	
}

Test liveness by detecting blinking

TFFBlinkDetection* bd = [sdk detectBlink];
If (bd.isBlinking) {
	
}

Detect largest face

TFFaceBoxAndLandmarks *fbl = [sdk detectLargestFace];
if (fbl.score > 0.9f) {
	
}

Face recognition

TFErrorCode errorCode = [self setImage:@"mr_bean"];
NSArray* v1 = [sdk getLargestFaceFeatureVector];
    
errorCode = [self setImage:@"mr_bean_2"];
NSArray* v2 = [sdk getLargestFaceFeatureVector];
    
TFSimilarity *similarity = [sdk getSimilarity:v1 :v2];
if (similarity.similarityMeasure > 0.6f && similarity.matchProbability > 0.9f) {
	
}

Post estimation

TFFaceBoxAndLandmarks *fbl = [sdk detectLargestFace];
TFEstimateHeadOrientation *eho = [sdk estimateHeadOrientation:fbl];
if (eho.yaw > 0.74f &&
        eho.yaw < 1.02f &&
        eho.pitch > -0.05f &&
        eho.pitch < 0.20f &&
        eho.roll > 0.06f &&
        eho.roll < 0.28f) {
        ...
} 

API

TFSDK class

// parent SDK version
-(NSString*)getVersion;
// mobile SDK version
-(NSString*)getMobileVersion;

// Validates the given license token. Need to call this method before being able to use the SDK.
-(BOOL)setLicense:(NSString*)token;
-(BOOL)isLicensed;

// Set the image that is processed by the other methods.
-(TFErrorCode)setImage:(UIImage *)image;

// Detect people and objects in the image.
-(NSSet*)detectObjects;
// Estimate score for eyes blink
-(TFFBlinkDetection*)detectBlink;

// Detect the largest face in the image.
-(TFFaceBoxAndLandmarks*)detectLargestFace;
// Detect the largest face in the image and return its feature vector.
-(NSArray*)getLargestFaceFeatureVector;
// Compute the similarity between two feature vectors, or how similar two faces are.
-(TFSimilarity*)getSimilarity:(NSArray*) vector1 :(NSArray*) vector2;
// Estimate the head pose.
-(TFEstimateHeadOrientation*)estimateHeadOrientation:(TFFaceBoxAndLandmarks*)tffbl;

TFSimilarity class

@property(assign) float matchProbability;
@property(assign) float similarityMeasure;

TFEstimateHeadOrientation

@property(assign) float yaw;
@property(assign) float pitch;
@property(assign) float roll;

TFFBlinkDetection

@property(assign) float threshold;
@property(assign) float leftEyeWinkScore;
@property(assign) float rightEyeWinkScore;
@property(assign) BOOL isBlinking;

TFFaceBoxAndLandmarks

@property(strong) TFPoint *topLeft;
@property(strong) TFPoint *bottomRight;
@property(strong) NSArray *landmarks;
@property(assign) float score;

TFBoundingBox

@property(assign) NSString *label;
@property(assign) float probability;
@property(strong) TFPoint *topLeft;
@property(assign) float width;
@property(assign) float height;

TFPoint

@property(assign) float x;
@property(assign) float y;

List of Enums

/** error codes returned by methods */
typedef enum
{
    NO_ERROR,
    INVALID_LICENSE,
    FILE_READ_FAIL,
    UNSUPPORTED_IMAGE_FORMAT,
    UNSUPPORTED_MODEL,
    NO_FACE_IN_FRAME,
    FAILED
} TFErrorCode;

/** image color formats */
typedef enum
{
    bgr,
    rgb,
    gray,
    yuv_i420,
    yuv_nv12
} TFColorCode;

/** object classes */
typedef enum
{
    background,
    aeroplane,
    bicycle,
    bird,
    boat,
    bottle,
    bus,
    car,
    cat,
    chair,
    cow,
    diningtable,
    dog,
    horse,
    motorbike,
    person,
    pottedplant,
    sheep,
    sofa,
    train,
    tvmonitor
} TFObjectLabel;

/** facial recognition models — FULL model is not supported on Mobile*/
typedef enum
{
    LITE
} TFFacialRecognitionModel;

/** object detection models */
typedef enum
{
    ACCURATE,
    FAST
} TFObjectDetectionModel;

Updated about a month ago

Trueface SDK for iOS


Getting started with Trueface SDK for iOS

Suggested Edits are limited on API Reference Pages

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