Introduction
EmotionDetector is a fully configurable library that makes use of face-api.js to detect:
Getting Started
Install
npm install @iad-os/emotion-detector
Usage Example
For a complete usage example could the see the demo project. However, there's the minimal code to use the component:
<EmotionDetector
onEmotionDetect={(detection: Detection) => {
//... some stuff with Detection object
}}
detecting={true}
/>
Available props
Required Props
Key | Type | Description | Default |
---|
detecting | boolean | Enable/Disable Detection | |
Additional Props
Key | Type | Description | Default |
---|
onEmotionDetect | Function | Called on each detection. Returns a Detection object. | |
emotionDetectPeriod | number | Specifies the period between onEmotionDetect calls | 1000 |
detectionPeriodMillis | number | Set detection period of face-api in milliseconds | 1000 |
emoThreshold | number | Set a minimum percentage to say a emotion is for sure the one detected. Ex: if "happy" percentage is < emoThreshold, say it's positive. | 60 |
detectAge | boolean | Enable/Disable Age detection | true |
detectSex | boolean | Enable/Disable Sex Detection | true |
showCam | boolean | Show/Hide Cam Component | true |
camSizeRatio | number | Size ratio of the cam component. "1" is the Max Cam Size Resolution. | 1 |
showLabel | boolean | Show/Hide Label component | true |
labelFormat | string | Detection label format. Available values: "text", "emoji", "both". The Default value depend on the camSizeRatio and on the cam size. | "both" |
text | string | Custom label text | |
labelStyle | React.CSSProperties | Custom label style | |