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

Chapter 3. Easy Object Detection for Everyone

In the last chapter, We discussed fundamental topics such as matrix operations and matrix convolutions. Moreover, we saw how to apply various image filters and how to use them in our applications. But those topics are mostly about image processing, not about Computer Vision! What do Computer Vision methods do by themselves? They provide the ability to understand an image by analyzing it in such a manner that the computer can provide the information about objects of an image scene. Libraries, which we discussed previously, provide various functionalities to find different objects in an image. In this chapter, we will mainly discuss methods that are included in the tracking.js (http://trackingjs.com) and JSFeat (http://inspirit.github.io/jsfeat/) libraries to get objects from an image. We will see how to find a colored object, and how to find an object using a template. Further, we will create our own object detector. These techniques can be implemented...

Detecting color objects


In the previous chapters, we worked mainly with grayscale images. Of course, the shape and intensity parts of objects are important, but what about the color information? Why don't we use that too? For example, a red apple on a table can be easily detected with just the color information. Actually, that is why color object detection sometimes performs much better than other detector methods. In addition, it is much faster to implement these algorithms, and a computer usually consumes less resources for these types of operation.

The tracking.js library provides an outstanding functionality to create a color detection application. We will start from a basic color tracking example. It is relatively simple, but you need to keep in mind that it performs best only when a colored object can be easily separated from the background.

Using predefined colors with the tracking.js library

Color detection is one of the methods provided by tracking.js. To use it properly, we need to...

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...

Image features


Color object detection and detection of changes in intensity of an image, is a simple Computer Vision method. It is a fundamental thing which every Computer Vision enthusiast should know. To get a better picture of Computer Vision capabilities, we will see how to find an object on a scene using a template. This topic includes several parts: feature extraction and descriptor matching. In this part, we will discuss feature detection and its application in Computer Vision.

Detecting key points

What information do we get when we see an object on an image? An object usually consists of some regular parts or unique points, which represent the particular object. Of course, we can compare each pixel of an image, but it is not a good idea in terms of computational speed. We can probably take unique points randomly, thus reducing the computation cost significantly. However, we will still not get much information from random points. Using the whole information, we can get too much noise...

Descriptors and object matching


Image features by themselves are a bit useless. Yes, we have found unique points on an image. But what did we get? Only pixels values and that's it. If we try to compare those values it will not give us much information. Moreover, if we change the overall image brightness, we will not find the same keypoints on the same image! Taking into account all of this, we need the information which surrounds our key points. Moreover, we need a method to efficiently compare this information. First, we need to describe the image features, which comes from image descriptors. In this part, we will see how those descriptors can be extracted and matched. The tracking.js and JSFeat libraries provide different methods for image descriptors. We will discuss both.

The BRIEF and ORB descriptors

The descriptors theory is focused on changes in an image pixels' intensities. The tracking.js library provides the Binary Robust Independent Elementary Features (BRIEF) descriptors and the...

Summary


We completed one of the hardest chapters in this book. Congratulations! We saw how to find and track a basic colored object and plunged into the depths of library APIs. Oh, and don't forget, we have completed our own object detector! The applications of Computer Vision methods vary. What we cannot accomplish with the simple color detection, we achieve with powerful feature detection and descriptor matching algorithms. Both libraries provide different functionalities to match the objects and some functions are not included in the libraries. But it should not stop you from using those excellent methods. To know how and, probably the more important part, when to use those algorithms are the most crucial things you need to know.

One of the most commonly seen objects in our world is a person's face. We interact with people everywhere. However, we did not see how to detect such objects in an application. The algorithms we covered in this chapter are not so useful for face detection, which...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Computer Vision for the Web
Published in: Oct 2015Publisher: PacktISBN-13: 9781785886171
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

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