Reader small image

You're reading from  Computer Vision for the Web

Product typeBook
Published inOct 2015
Reading LevelIntermediate
PublisherPackt
ISBN-139781785886171
Edition1st Edition
Languages
Right arrow
Author (1)
Foat Akhmadeev
Foat Akhmadeev
author image
Foat Akhmadeev

Foat Akhmadeev has 5 years of experience in software development and research. He completed his master's degree in the year 2014 from the Kazan Federal University, Russia. He has worked on different projects, including development of high-loaded websites written in Java and real-time object detection for mobile phones. He has an extensive background in the field of Computer Vision. He has also written a scientific paper on 3D reconstruction from a single image. For more information, you can visit his website at http://foat.me.
Read more about Foat Akhmadeev

Right arrow

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 in the tag itself. To run a tracker, we just need to set the tag id as a first parameter:

tracking.track('#img', tracker);

Next comes the <video> tag. In our <div> element, which wraps the canvas, we need to...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Computer Vision for the Web
Published in: Oct 2015Publisher: PacktISBN-13: 9781785886171

Author (1)

author image
Foat Akhmadeev

Foat Akhmadeev has 5 years of experience in software development and research. He completed his master's degree in the year 2014 from the Kazan Federal University, Russia. He has worked on different projects, including development of high-loaded websites written in Java and real-time object detection for mobile phones. He has an extensive background in the field of Computer Vision. He has also written a scientific paper on 3D reconstruction from a single image. For more information, you can visit his website at http://foat.me.
Read more about Foat Akhmadeev