Skip to content

Commit c057fa0

Browse files
committed
Use the 'face' event for Facemesh event emitter
1 parent c12b0ca commit c057fa0

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

docs/reference/facemesh.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function modelLoaded() {
2626
console.log('Model Loaded!');
2727
}
2828

29-
// Listen to new 'predict' events
30-
facemesh.on('predict', results => {
29+
// Listen to new 'face' events
30+
facemesh.on('face', results => {
3131
predictions = results;
3232
});
3333
```
@@ -135,19 +135,19 @@ const facemesh = ml5.facemesh(?video, ?options, ?callback);
135135
136136
***
137137
138-
#### .on('predict', ...)
138+
#### .on('face', ...)
139139
> An event listener that returns the results when a new face detection prediction occurs.
140140
141141
```js
142-
facemesh.on('predict', callback);
142+
facemesh.on('face', callback);
143143
```
144144
145145
📥 **Inputs**
146146
147147
* **callback**: REQUIRED. A callback function to handle new face detection predictions. For example:
148148
149149
```js
150-
facemesh.on('predict', results => {
150+
facemesh.on('face', results => {
151151
// do something with the results
152152
console.log(results);
153153
});

examples/p5js/Facemesh/Facemesh_Image/sketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function setup() {
1919
function imageReady() {
2020
facemesh = ml5.facemesh(modelReady);
2121

22-
facemesh.on("predict", results => {
22+
facemesh.on("face", results => {
2323
predictions = results;
2424
});
2525
}

examples/p5js/Facemesh/Facemesh_Webcam/sketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function setup() {
1111

1212
// This sets up an event that fills the global variable "predictions"
1313
// with an array every time new predictions are made
14-
facemesh.on("predict", results => {
14+
facemesh.on("face", results => {
1515
predictions = results;
1616
});
1717

src/Facemesh/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ class Facemesh extends EventEmitter {
6464
const { flipHorizontal } = this.config;
6565
const predictions = await this.model.estimateFaces(input, flipHorizontal);
6666
const result = predictions;
67+
// Soon, we will remove the 'predict' event and prefer the 'face' event. During
68+
// the interim period, we will both events.
6769
this.emit("predict", result);
70+
this.emit("face", result);
6871

6972
if (this.video) {
7073
return tf.nextFrame().then(() => this.predict());

0 commit comments

Comments
 (0)