Home Reference Source
import FaceAPI from 'sayhello/js/faceapi.js'
public class | source

FaceAPI

Used for accessing Microsoft's Face API. Written for general use cases, not specifically for this application.

Constructor Summary

Public Constructor
public

creates an instance of FaceAPI

Member Summary

Public Members
public

key: *

type {number}

Method Summary

Public Methods
public

addPersonFace(personGroupId: string, personId: string, image: Object, faceRectangle: Object): Object

add a PersonFace to a Person

public

createPerson(personGroupId: string, name: string, userData: string): Object

create a Person

public

createPersonGroup(personGroupId: string): Object

creates a personGroup with name identical to the id.

public

deletePerson(personGroupId: string, personId: string): Object

deletes a person

public

detect(image: blob): Object

detects faces in an image

public

getPersonGroup(personGroupId: number): Object

fetches a personGroup

public

checks if personGroup exists and if it doesn't, creates it.

public

identify(personGroupId: string, faceIds: string[]): Object

identifies persons from faceIds

public

listPersons(personGroupId: string): Object

lists all Persons of a PersonGroup

public

makeRequest(endpoint: string, method: string, headers: Object, isImage: boolean): Object

makes a request to the API, used for simplifying.

public

setKey(key: *)

type {string}

public

trainPersonGroup(personGroupId: string): Object

trains a personGroup

Public Constructors

public constructor(key: string) source

creates an instance of FaceAPI

Params:

NameTypeAttributeDescription
key string

API key

Public Members

public key: * source

type {number}

Public Methods

public addPersonFace(personGroupId: string, personId: string, image: Object, faceRectangle: Object): Object source

add a PersonFace to a Person

Params:

NameTypeAttributeDescription
personGroupId string
personId string
image Object
faceRectangle Object

Return:

Object

fetch request

public createPerson(personGroupId: string, name: string, userData: string): Object source

create a Person

Params:

NameTypeAttributeDescription
personGroupId string
name string

Name to display

userData string
  • optional

Secret data

Return:

Object

fetch request

public createPersonGroup(personGroupId: string): Object source

creates a personGroup with name identical to the id.

Params:

NameTypeAttributeDescription
personGroupId string

Return:

Object

fetch request

public deletePerson(personGroupId: string, personId: string): Object source

deletes a person

Params:

NameTypeAttributeDescription
personGroupId string
personId string

Return:

Object

fetch request

public detect(image: blob): Object source

detects faces in an image

Params:

NameTypeAttributeDescription
image blob

Return:

Object

fetch request

public getPersonGroup(personGroupId: number): Object source

fetches a personGroup

Params:

NameTypeAttributeDescription
personGroupId number

Return:

Object

fetch request

public getPersonGroupOrCreate(personGroupId: string): Object source

checks if personGroup exists and if it doesn't, creates it.

Params:

NameTypeAttributeDescription
personGroupId string

Return:

Object

fetch request

public identify(personGroupId: string, faceIds: string[]): Object source

identifies persons from faceIds

Params:

NameTypeAttributeDescription
personGroupId string
faceIds string[]

Return:

Object

fetch request

public listPersons(personGroupId: string): Object source

lists all Persons of a PersonGroup

Params:

NameTypeAttributeDescription
personGroupId string

Return:

Object

fetch request

public makeRequest(endpoint: string, method: string, headers: Object, isImage: boolean): Object source

makes a request to the API, used for simplifying.

Params:

NameTypeAttributeDescription
endpoint string

Endpoint to access in request

method string
  • optional
  • default: 'GET'

Method to use for request, e.g. GET, POST, PUT, etc.

headers Object
  • optional
  • default: { 'Ocp-Apim-Subscription-Key': this.key, 'Content-Type': 'application/json', Accept: 'application/json' }

Headers to send

isImage boolean
  • optional

If an image is in the body

Return:

Object

fetch request or error

public setKey(key: *) source

type {string}

Params:

NameTypeAttributeDescription
key *

public trainPersonGroup(personGroupId: string): Object source

trains a personGroup

Params:

NameTypeAttributeDescription
personGroupId string

Return:

Object

fetch request