O'Reilly logo

Computer Vision for the Web by Foat Akhmadeev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Digging into the tracking.js API

We saw a color tracker and added our own color matcher. The tracking.js library provides an excellent functionality to add a new object detector. It has a clear API and good documentation to follow (http://trackingjs.com/docs.html). But first, we will see how to use a tracker with different HTML tags and dig a bit into the tracker API.

Using the <img> and <video> tags

The library uses a <canvas> tag to operate with images. If you run a tracker on a different tag, then the library will convert the information from it to the canvas automatically.

First of all, tracking can be applied to an <img> tag:

<img id="img" src="/path/to/your/image.jpg"/>

In that case, we can specify the image path not in a JavaScript code, but ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required