-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathWorker.js
More file actions
executable file
·27 lines (21 loc) · 869 Bytes
/
Worker.js
File metadata and controls
executable file
·27 lines (21 loc) · 869 Bytes
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
onmessage=function (evt) {
console.log('Message received from main script'+evt);
var tracker = new tracking.ObjectTracker([ 'eye']);
tracker.setStepSize(1.7);
tracking.track('#previewImage', tracker);
tracker.on('track', function(event) {
event.data.forEach(function(rect) {
window.plot(rect.x, rect.y, rect.width, rect.height);
});
});
window.plot = function(x, y, w, h) {
var rect = document.createElement('div');
document.querySelector('mainArea').appendChild(rect);
rect.classList.add('rect');
rect.style.width = w + 'px';
rect.style.height = h + 'px';
rect.style.left = (previewImage.offsetLeft + x) + 'px';
rect.style.top = (previewImage.offsetTop + y) + 'px';
};
postMessage(rect);
};