-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwidget.js
executable file
·29 lines (24 loc) · 1.01 KB
/
widget.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
WAF.define('FaceDetection', function() {
var widget = WAF.require('waf-core/widget');
var FaceDetection = widget.create('FaceDetection');
//in the Init phase of your widget, bind the code that is fired when the event occurs
FaceDetection.prototype.init = function () {
if(window.tracking) {
this.videoCamera = new tracking.VideoCamera().hide().render(this.node).renderVideoCanvas(this.node);
var ctx = this.videoCamera.canvas.context;
this.videoCamera.track({
type: 'human',
data: 'frontal_face',
onFound: function(track) {
for (var i = 0, len = track.length; i < len; i++) {
var rect = track[i];
ctx.strokeStyle = "rgb(0,255,0)";
ctx.strokeRect(rect.x, rect.y, rect.size, rect.size);
}
}
});
}
}
return FaceDetection;
});
// For more information, refer to http://doc.wakanda.org/Wakanda0.DevBranch/help/Title/en/page3871.html