eduardolundgren / tracking.js

A modern approach for Computer Vision on the web
http://trackingjs.com
Other
9.43k stars 1.44k forks source link

Check the size of the rectangle #355

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi!

Is it possible to check the dimensions of the rectangle? just like the color, width, height etc.

BhavitChhatralia commented 5 years ago

@tanerolcxy Believe you want something like this: `event.data.forEach(function(rect) { //Replace code here to do something else once working correctly

                //draw basic rectangle around face colour black
                context.strokeStyle = '#fff';
                context.strokeRect(rect.x, rect.y, rect.width, rect.height);
                // select size of font
                context.font = '11px Helvetica';
                //font colour
                context.fillStyle = "#fff";
                //text to be displayed around face rectangle(will be displayed on the right)
                context.fillText('x: ' + rect.x + 'px', rect.x + rect.width + 5, rect.y + 11); // to show xpx
                context.fillText('y: ' + rect.y + 'px', rect.x + rect.width + 5, rect.y + 22); // to show ypx
            });
        });`

This is taken from the example page so nothing here apart from comments are mine.