new VisageFaceAnalyser()
VisageFaceAnalyser contains face analysis algorithms capable of estimating gender and emotion from frontal facial images (yaw between -20 and 20 degrees).
Following types of analysis can be used:
Note: After the end of use VisageFaceAnalyser object needs to be deleted to release the allocated memory. Example:
VisageFaceAnalyser class requires, by default, data files bundled in visageAnalysisData.data file and a loader script visageAnalysisData.js located in www/lib folder. Files for VisageFaceAnalyser are bundled and loaded separately from files bundled for VisageTracker class.
For every application using VisageFaceAnalyser API, visageAnalysisData.data file and visageAnalysisData.js loading script must be copied to the same folder where the application's main html file is located (e.g. Samples/ShowcaseDemo folder).
Additionally, visageAnalysisData.js script must be loaded after the main visageSDK.js script has been loaded and after VisageModule object has been created.
For example - loading visageAnalysisData.data file:
If webassembly format is used, then the visageSDK.wasm file is also expected to be located in the same folder as the application's main html file.
Changing the location of the .data file
Location of the .data and .wasm files can be changed by overriding the locateFile attribute of the VisageModule object to return the URL where the data file is currently stored. Note that all visage|SDK data files (visageSDK.data, visageRecognitionData.data and visageAnalysisData.data) and .wasm file must be loacated in the same folder (i.e same URL) (see www/Samples/FaceTracer/sampleTracker.html). This additional code needs to be added to the application's main html file and the VisageModule' attribute must be specified in a script element before the one that loads the data file (in this case visageSDK.js and visageAnalysisData.js).
Sample usage - changing .data and .wasm files location:
Following types of analysis can be used:
ANALYSIS TYPE | FUNCTION |
age estimation | estimateAge() |
gender estimation | estimateGender() |
emotion estimation | estimateEmotion() |
Note: After the end of use VisageFaceAnalyser object needs to be deleted to release the allocated memory. Example:
<script>
m_FaceAnalyser = new VisageModule.VisageFaceAnalyser();
...
m_FaceAnalyser.delete();
</script>
Dependencies
VisageFaceAnalyser class requires, by default, data files bundled in visageAnalysisData.data file and a loader script visageAnalysisData.js located in www/lib folder. Files for VisageFaceAnalyser are bundled and loaded separately from files bundled for VisageTracker class.
For every application using VisageFaceAnalyser API, visageAnalysisData.data file and visageAnalysisData.js loading script must be copied to the same folder where the application's main html file is located (e.g. Samples/ShowcaseDemo folder).
Additionally, visageAnalysisData.js script must be loaded after the main visageSDK.js script has been loaded and after VisageModule object has been created.
For example - loading visageAnalysisData.data file:
<script src="../../lib/visageSDK.js"></script>
<script>
var VisageModule = VisageModule({onRuntimeInitialized: onModuleInitialized});
</script>
<script src="visageAnalysisData.js"></script>
If webassembly format is used, then the visageSDK.wasm file is also expected to be located in the same folder as the application's main html file.
Changing the location of the .data file
Location of the .data and .wasm files can be changed by overriding the locateFile attribute of the VisageModule object to return the URL where the data file is currently stored. Note that all visage|SDK data files (visageSDK.data, visageRecognitionData.data and visageAnalysisData.data) and .wasm file must be loacated in the same folder (i.e same URL) (see www/Samples/FaceTracer/sampleTracker.html). This additional code needs to be added to the application's main html file and the VisageModule' attribute must be specified in a script element before the one that loads the data file (in this case visageSDK.js and visageAnalysisData.js).
Sample usage - changing .data and .wasm files location:
<script>
var locateFile = function(dataFileName) {var relativePath = "../../lib/" + dataFileName; return relativePath}
</script>
<script src="../../lib/visageSDK.js"></script>
<script>
VisageModule = VisageModule({onRuntimeInitialized: onModuleInitialized, locateFile: locateFile});
</script>
Methods
-
estimateGender(frameWidth, frameHeight, p_imageData, faceData) → {number}
-
Estimates gender from a facial image.
The function returns 1 if estimated gender is male and 0 if it is a female. Prior to using this function, it is necessary to process the facial image or video frame using VisageTracker or VisageDetector. This function estimates gender for last image processed by VisageTracker.track() or VisageDetector.detectFeatures() function.Parameters:
Name Type Description frameWidth
number Width of the frame frameHeight
number Height of the frame p_imageData
number Pointer to image pixel data, size of the array must correspond to frameWidth and frameHeight. Allowed image formats are RGB and RGBA. faceData
FaceData FaceData object filled with tracking results from a previous call of the VisageTracker.track() or VisageDetector.detectFeatures() function. Returns:
returns 0 if estimated gender is female, 1 if it is a male and -1 if it failed.- Type
- number
-
estimateEmotion(frameWidth, frameHeight, p_imageData, faceData, emotion_probabilities) → {number}
-
Estimates emotion from a facial image.
The function returns estimated probabilities for basic emotions. Prior to using this function, it is necessary to process the facial image or video frame using VisageTracker or VisageDetector. This function estimates emotions for last image processed by VisageTracker.track() or VisageDetector.detectFeatures() function.Parameters:
Name Type Description frameWidth
number Width of the frame frameHeight
number Height of the frame p_imageData
number Pointer to image pixel data, size of the array must correspond to frameWidth and frameHeight. Allowed image formats are RGB and RGBA. faceData
FaceData FaceData object filled with tracking results from a previous call of the VisageTracker.track() or VisageDetector.detectFeatures() function. emotion_probabilities
VectorFloat array of 7 floats. If successful, the function will fill this array with estimated probabilities for emotions in this order: anger, disgust, fear, happiness, sadness, surprise and neutral. Each probability will have a value between 0 and 1. Sum of probabilities does not have to be 1. - See:
Returns:
returns 1 if estimation was successful or 0 if estimation was unsuccessful.- Type
- number
-
estimateAge(frameWidth, frameHeight, p_imageData, faceData) → {number}
-
Estimates age from a facial image.
The function returns estimated age. Prior to using this function, it is necessary to process the facial image or video frame using VisageTracker. This function estimates age for for last image processed by VisageTracker.track() or VisageDetector.detectFeatures() function.Parameters:
Name Type Description frameWidth
number Width of the frame frameHeight
number Height of the frame p_imageData
number Pointer to image pixel data, size of the array must correspond to frameWidth and frameHeight. Allowed image format is RGB. faceData
FaceData FaceData object filled with tracking results from a previous call of the VisageTracker.track() or VisageDetector.detectFeatures() function. Returns:
returns estimated age if estimation was successful or -1 if it failed.- Type
- number