You can customize the detection model with the following options:
const options = {
model: 'advanced', # Can be 'basic' or 'advanced'
threshold: 0.8 # Minimum confidence threshold
};
EmotionDetection.detectEmotion('path/to/image.jpg', options)
.then(result => console.log(result))
.catch(error => console.error(error));
Cite
If you are using this GitHub Repository, please cite it in the following format:
@misc{mentalhealth-app,
author = {Utomo, Galih Ridho and Maulida, Ana},
title = {Mental Health Application with Face Recognition and Emotion Detection},
year = {2025},
howpublished = {\url{https://github.com/4211421036/MentalHealth}},
note = {GitHub repository},
}
Mental Health Application Based Face Recognition
Key Features:
Formulation
The hash function is used to generate a unique
FaceIDbased on facial landmarks. The formula for the hash function is:hash=5381for each character i in the string:hash=(hash×33)+charCodeAt(i)return hash >>0(unsigned 32-bit integer)
The lip stretch is calculated using the Euclidean distance between the left and right lip corners:
lipStretch=(x2−x1)2+(y2−y1)2
The cheek raise is calculated as the vertical distance between the cheek and eye landmarks:
cheekRaise=yeye−ycheek
The lip depression is calculated as the vertical distance between the lip corner and the bottom lip:
lipDepression=ybottomLip−ylipCorner
The brow lowering is calculated as the vertical distance between the inner and outer brow landmarks:
browLower=yinnerBrow−youterBrow
The eye openness is calculated as the vertical distance between the eyelid and eye landmarks:
eyeOpenness=yeye−yeyelid
The jaw drop is calculated as the vertical distance between the chin and nose landmarks:
jawDrop=ychin−ynose
The deviation from neutral is calculated as the sum of Euclidean distances between key facial landmarks:
deviation=(x2−x1)2+(y2−y1)2
The total deviation from neutral is calculated as the sum of Euclidean distances between key facial landmarks:
deviation=i=1∑n(x2i−x1i)2+(y2i−y1i)2
Technologies:
Usage:
How To Use this Package
You can copy the command line below:
Import Modules into Project
If using
CommonJS:or If using
ES Module (ESM):Detecting Emotion from Face Images
Use the
detectEmotion(imagePath)function to detect emotions from facial images:Sample Output:
Detecting Emotion from Camera in Real-Time
If you want to detect emotions from the camera, use the
detectEmotionLive()function:Additional Configuration (Optional)
You can customize the detection model with the following options:
Cite
If you are using this GitHub Repository, please cite it in the following format:
Authors