<body>
@xingwangdev/jsface
This is a powerful JavaScript library that provides face detection and landmark extraction functionalities for your applications. It allows you to easily integrate face-related features into your projects, enabling you to detect faces in images and extract landmarks with ease.
Installation
To install the @xingwangdev/jsface
package, simply run the following command:
npm install @xingwangdev/jsface
Table of Contents
Face Detection
Load detection model
To begin detecting faces, you need to load the detection model. Use the following function:
loadDetectionModel()
Detect face in the image
Once the detection model is loaded, you can detect faces in an image by invoking the detectFace
function:
detectFace(session, canvas_id)
Here, session
represents the current session, which is the result of loadDetectionModel
or loadLandmarkModel
and canvas_id
is the ID of the canvas element where the image is displayed.
Face Landmark Extraction
Load landmark extraction model
To extract face landmarks, you must first load the landmark extraction model. Use the following function:
loadLandmarkModel()
Extract face landmark in the image using detection result
After loading the landmark extraction model, you can extract face landmarks using the detection result. Invoke the predictLandmark
function as shown below:
predictLandmark(session, canvas_id, bbox)
In the above code, session
represents the current session, which is the result of loadDetectionModel
or loadLandmarkModel
and canvas_id
is the ID of the canvas element displaying the image, and bbox
is the bounding box obtained from the face detection process.
Feel free to explore the provided functionalities and integrate them into your applications.
</body> </html>