Book Image

Computer Vision for the Web

By : Foat Akhmadeev
Book Image

Computer Vision for the Web

By: Foat Akhmadeev

Overview of this book

This book will give you an insight into controlling your applications with gestures and head motion and readying them for the web. Packed with real-world tasks, it begins with a walkthrough of the basic concepts of Computer Vision that the JavaScript world offers us, and you’ll implement various powerful algorithms in your own online application. Then, we move on to a comprehensive analysis of JavaScript functions and their applications. Furthermore, the book will show you how to implement filters and image segmentation, and use tracking.js and jsfeat libraries to convert your browser into Photoshop. Subjects such as object and custom detection, feature extraction, and object matching are covered to help you find an object in a photo. You will see how a complex object such as a face can be recognized by a browser as you move toward the end of the book. Finally, you will focus on algorithms to create a human interface. By the end of this book, you will be familiarized with the application of complex Computer Vision algorithms to develop your own applications, without spending much time learning sophisticated theory.
Table of Contents (13 chapters)

Tagging people in photos


Tagging people in photos is a common procedure that you use a lot in social networks. If you want to create similar functionality on your website, the JavaScript world can offer something for you. Actually, you can do that with any library which provides face detection methods, you just need to write some additional methods. To simplify the code, we will follow an example from the tracking.js library. It is easy to understand and implement:

  1. First, we need to place our image to the HTML code:

    <div id="photo"><img id="img" src="/path/to/your/image.jpg"/></div>
  2. Here is an array that holds all the names that need to be tagged:

    var theBeatles = ['George Harrison', 'John Lennon', 'Ringo Starr', 'Paul McCartney'];
  3. Then, we start from initializing our ObjectTracker function with a face object:

    var tracker = new tracking.ObjectTracker('face');
  4. The whole magic goes on in a post processing function:

    tracker.on('track', function (event) {
        var data = event.data...