Home

Trueface SDK Nodejs Binding

How to Build

This Node binding is built upon the C Binding. There are some functions from C binding not available yet. Due to model file's size, it may require additional model file download to satisfy the SDK in production.

NPM Submission

In each stable release pipeline, the node binding package is submitted to [https://npmjs.org] automatically. Therefore it will have always the latest SDK reference.

Installation

npm install @trueface/trueface-sdk-javascript

or

yarn add @trueface/trueface-sdk-javascript

Usage

const SDK = require("@trueface/trueface-sdk-javascript)

const license = process.env.TRUEFACE_TOKEN

const sdk = new SDK({
  "frModel": 0, // 0: lite model, 1: tfv5 model
  "modelsPath": "."
}, ".");

sdk.setLicense(license)

if (!sdk.isLicensed()) return false

let errorCode = dk.setImageFromFile("./image/test.jpeg")
if (errorCode !== 0) return false

const imageProp = sdk.getImageProperties()
const face = sdk.detectLargestFace()

if (!face.found) return false
return face

Model Download

This is the main TFSDK class. In order for SDK to work, please first download the models files, only download the models which is required.

Download blink detector model

curl -O -L https://storage.googleapis.com/sdk-models/enc/blink/blink_detector_v1.trueface.enc

Download body pose estimator model

test -e body_pose_estimator_v1.trueface.enc || curl -O -L https://storage.googleapis.com/sdk-models/enc/body_pose_estimator/v1/body_pose_estimator_v1.trueface.enc

Download face landmarks v2 model

curl -O -L https://storage.googleapis.com/sdk-models/enc/landmark_detection/face_landmark_detector_v2.trueface.enc

Download face recognition lite v2 model

curl -O -L https://storage.googleapis.com/sdk-models/enc/face_recognition/cpu/face_recognition_cpu_lite_v2.trueface.enc

Download face recognition tfv4 cpu model

curl -O -L https://storage.googleapis.com/sdk-models/enc/face_recognition/cpu/face_recognition_cpu_v4.trueface.enc

Download face recognition tfv5 cpu model

curl -O -L https://storage.googleapis.com/sdk-models/enc/face_recognition/cpu/face_recognition_cpu_v5.trueface.enc

Download face recognition tfv4 gpu model

curl -O -L https://storage.googleapis.com/sdk-models/enc/face_recognition/gpu/face_recognition_gpu_v4.trueface.enc

Download face recognition tfv5 gpu model

curl -O -L https://storage.googleapis.com/sdk-models/enc/face_recognition/gpu/face_recognition_gpu_v5.trueface.enc

Download object detector v1 model

curl -O -L https://storage.googleapis.com/sdk-models/enc/object_detection/object_detector_v1.trueface.enc

Download spoof model

curl -O -L https://storage.googleapis.com/sdk-models/enc/spoof/v5/spoof_v5.trueface.enc

Then in your command line, run sh model_file.sh and place the model files in desired location, be sure to set the correct modelsPath in your sdk initialization.