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:
To Do:
  • fix rollup dependency pb with facelandmark dependency for browser usage

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:

emotions

Properties:
Name Type Description
Default

emotions computed by the API

Default Value:
  • ["attention","confusion","surprise","amusement","pitching","yawing"]
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:

model

Properties:
Name Type Description
Variable

to use the model that extract anonymized facial keypoints

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:

pitchingCallback

Properties:
Name Type Description
handler

for real-time yawing calculation received

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:

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:

videoAvailable

Properties:
Name Type Description
Indicate

if video is available in browser mode

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:

yawingCallback

Properties:
Name Type Description
handler

for real-time pitching calculation received

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> 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