I'm trying to do some color tracking on images with node.js. I found tracking.js to be quite suitable for the job. I've got the problem solved in the browser. As i tried to move things over to node.js, i realised that tracking.js depends on DOM elements to convert images to matrices, etc.
My usecase looks similar to this (from the tracking.js examples):
window.onload = function() {
var img = document.getElementById('img');
var demoContainer = document.querySelector('.demo-container');
var tracker = new tracking.ColorTracker(['magenta', 'cyan', 'yellow']);
tracker.on('track', function(event) {
event.data.forEach(function(rect) {
window.plot(rect.x, rect.y, rect.width, rect.height, rect.color);
});
});
tracking.track('#img', tracker);
window.plot = function(x, y, w, h, color) {
console.log('found ',color,' at ',x,y,w,h) // these results would be used in node.js
var rect = document.createElement('div');
document.getElementById('bdy').appendChild(rect);
rect.classList.add('rect');
rect.style.border = '2px solid ' + color;
rect.style.width = w + 'px';
rect.style.height = h + 'px';
rect.style.left = (img.offsetLeft + x) + 'px';
rect.style.top = (img.offsetTop + y) + 'px';
};
};
As I understand they present a gulp test that works in the repo, but i can't find a proper module anywhere.
Is there an elegant alternative way to make tracking.js run on node.js?
The latest commit has absolved this problem (from issue #47).