Class: MojoPerceptionAPI

MojoPerceptionAPI

Javascript Client for Mojo Perception API
See README for a procedure to generate the required parameters :
auth_token, host, port and user_namespace


new MojoPerceptionAPI(auth_token, host, port, user_namespace)

Parameters:
Name Type Description
auth_token string

Token generated from a valid API Key.

host string

API Stream host

port string

API Stream port

user_namespace string

Namespace of the current token

Source:

Members


amusementCallback

Properties:
Name Type Description
handler

for real-time confusion calculation received

Source:

apiSocket

Properties:
Name Type Description
socket

io

Source:

attentionCallback

Properties:
Name Type Description
handler

for real-time attention calculation received

Source:

auth_token

Properties:
Name Type Description
access

key given by the API backend (access token with expiration date depending on the subscription)

Source:

confusionCallback

Properties:
Name Type Description
handler

for real-time surprise calculation received

Source:

currentWaitingTime

estimate the waiting time of the model to be downloaded in ms.

Source:

emotions

Properties:
Name Type Description
Default

emotions computed by the API

Default Value:
  • ["attention","confusion","surprise","amusement","engagement","interaction"]
Source:

engagementCallback

Properties:
Name Type Description
handler

for real-time engagement calculation received

Source:

firstEmitDone

Properties:
Name Type Description
Indicate

if the first emit has been done to the SocketIO stream server

Source:

firstEmitDoneCallback

Properties:
Name Type Description
called

when first emit to SocketIO stream server has been done

Source:

fps

Properties:
Name Type Description
performance

evaluated while computing

Source:

host

Properties:
Name Type Description
socket

io stream host

Source:

<readonly> initialized

Properties:
Name Type Description
set

to true when successfully loaded camera and connected to socketio stream

Default Value:
  • false
Source:

interactionCallback

Properties:
Name Type Description
handler

for real-time interaction calculation received

Source:

isCameraAccessGranted

Properties:
Name Type Description
True

if camera access has been successfully granted by the user, default false

Source:

maxWaitingTime

Properties:
Name Type Description
maximum

waiting time for the model to be downloaded after a camera launch. 30 sec default.

Source:

model

Properties:
Name Type Description
Variable

to use the model that extract anonymized facial keypoints

Source:

modelLoaded

Properties:
Name Type Description
indicates

when the asynchronous model loading procedure is done

Source:

nodeToAttachVideo :Node

Type:
  • Node
Properties:
Name Type Description
HTML

document node to attach video

Source:

onErrorCallback

Properties:
Name Type Description
called

if an error occurs

Source:

port

Properties:
Name Type Description
socket

io stream port

Source:

sending

Properties:
Name Type Description
set

to false to stop sending to the API

Source:

socketIoURI

Properties:
Name Type Description
Complete

URI for connection to Socket IO server

Source:

stepWaitingTime

Properties:
Name Type Description
step

for retrying to check if model is downloaded. 100 ms default.

Source:

stream

Properties:
Name Type Description
stream

of the user camera if granted, default null

Source:

subscribeRealtimeOutput

Properties:
Name Type Description
flag

to indicate if the API subscribes to real-time calculation (optional)

Source:

surpriseCallback

Properties:
Name Type Description
handler

for real-time amusement calculation received

Source:

user_namespace

Properties:
Name Type Description
namespace

for the user token

Source:

videoNodeParameters :json

Type:
  • json
Properties:
Name Type Description
optional

parameters for the HTML video node element

Source:

videoSectionName

Properties:
Name Type Description
Default

name for video tag in browser mode

Default Value:
  • "video_display"
Source:

warmUpDoneCallback

Properties:
Name Type Description
called

when camera is loaded + socketio connected + facemesh calculation loop warmed up

Source:

Methods


<async> computeAnonymizedFaceMeshFromHTMLVideoTag()

Compute anonymized facemesh for the current video frame, and call the emit function

Source:
Returns:

true

Type
bool

defaultCallback(message)

Used by default for all callbacks. Does nothing

Parameters:
Name Type Description
message string

not used

Source:

defaultFirstEmitDoneFallback(message)

Called when the first emit to the Stream SocketIO server is done

Parameters:
Name Type Description
message string

not used

Source:

emitFacemesh(facemesh)

Send the facemesh to the streaming SocketIO server

Parameters:
Name Type Description
facemesh facemesh

computed facemesh from video input

Source:
Returns:

true

Type
bool

<async> init()

Initialize MojoPerceptionAPI, called once. Place default callbacks on
calculation reception for each emotion and load the anonymization model

Source:
Returns:

true

Type
bool

<async> releaseCamera()

Release the camera

Source:
Returns:

true

Type
bool

setOptions(options)

Set options for MojoPerceptionAPI, to change the list of emotions calculated and
manage subscription to realtime output

Parameters:
Name Type Description
options dict

options["emotions"] : list of emotions to be calculated by the API
options["subscribeRealtimeOutput"] : boolean, true to activate the callbacks @see attentionCallback

Source:

<async> setupCameraFromBrowser()

Setup camera in browser context

Source:
Returns:

video tag

Type
Future

<async> startCameraAndConnectAPI()

While model is loaded, get access to the camera and connect to socketIO

Source:

<async> stopFacialExpressionRecognitionAPI()

Stop sending to the API, remove video in browser mode, disconnect from the stream
SocketIO server and release the camera.

Source:
Returns:

true

Type
bool

toString()

Return a string representing the MojoPerceptionAPI object

Source:
Returns:

emotions, socketIoURI, subscription status and key

Type
string

<async> waitLoadingModelFinished()

Waiting loop for initialization purpose, if API calls done before model downloaded

Source: