Reader small image

You're reading from  Computer Vision with OpenCV 3 and Qt5

Product typeBook
Published inJan 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788472395
Edition1st Edition
Languages
Right arrow
Author (1)
Amin Ahmadi Tazehkandi
Amin Ahmadi Tazehkandi
author image
Amin Ahmadi Tazehkandi

Amin Ahmadi Tazehkandi is an Iranian author, developer, and a computer vision expert.Amin Ahmadi Tazehkandi is an Iranian author, developer, and a computer vision expert. He completed his computer software engineering studies in Iran and has worked for numerous software and industrial companies around the world.
Read more about Amin Ahmadi Tazehkandi

Right arrow

Chapter 7. Features and Descriptors

In Chapter 6, Image Processing in OpenCV, we learned about image processing mostly in terms of the image content and pixels. We learned how to filter them, transform them, or play around with the pixel values in one way or another. Even to match a template, we simply used the raw pixel contents to get a result and find out if an object exists in part of an image or not. However, we still haven't learned about the algorithms that allow us to differentiate between objects of a different kind, not just based on their raw pixels, but also the collective meaning of an image based on its specific features. It is almost a trivial task for a human being to identify and recognize different types of faces, cars, written words, and almost any visible and visual object, given that they are not extremely similar. For us human beings, this happens in most cases without us even thinking about it. We can differentiate even between very similar faces, based on small and...

Base of all algorithms – the Algorithm class


All algorithms in OpenCV, or better yet, at least the ones that are not too short and simple, are created as subclasses of the cv::Algorithm class. This class, as opposed to what you would normally expect, is not an abstract class, which means you can create instances of it, which simply do nothing. Even though this may be changed sometime in the future, it doesn't really affect the way we will access and use it. The way the cv::Algorithm class is used in OpenCV, and also the recommended way in case you want to create your own algorithms, is that first a subclass of cv::Algorithm that contains all required member functions for a specific purpose or goal gets created. Then, this newly created subclass can be again subclassed to create implementations of the same algorithm. To better understand this, let's first see the cv::Algorithm class in detail. Here's (roughly) how it looks if you take a peek at the OpenCV source codes:

    class Algorithm...

The 2D Features Framework


As it was mentioned previously in this chapter, OpenCV classes to perform various feature detection and descriptor extraction algorithms created by computer vision researchers from all across the world. Just like any other complex algorithm implemented in OpenCV, feature detectors and descriptor extractors are also created by subclassing the cv::Algorithm class. This subclass is called Feature2D, and it contains various functions that are common to all feature detection and descriptor extraction classes. Basically, any class that can be used to detect features and extracts descriptors should be a subclass of Featured2D. OpenCV uses the following two class types for this purpose:

  • FeatureDetector
  • DescriptorExtractor

It's important to note that both of these classes are, in fact, just a different name for Feature2D since they are created inside OpenCV using the following typedef statements (we'll talk about the reason for this later on in this section):

    typedef Feature2D...

How to choose an algorithm


As it was mentioned, there is no that can be easily used for all out-of-the-box cases, and the main reason for this is the huge variety of software and hardware related factors. An algorithm may be highly accurate, but, at the same time, it may require lots of resources (such as memory or CPU usage).

Another algorithm may require fewer parameters (which is almost always a relief), but then again, it may not be able to achieve its highest performance. We can't even begin to name all the possible factors that affect choosing the best Feature2D (or featured detector and descriptor extractor) algorithm or the best matching algorithm, but we can still take into consideration some of the main and more well-known factors that are also the reason why OpenCV and most computer vision algorithms are created the way they are, in terms of structure. Here are those factors:

  • Accuracy
  • Speed
  • Resource usage (memory, disk space, and so on)
  • Availability

Note that the word performance usually...

Summary


Feature detection, description, and matching are probably some of the most important and hot topics in computer vision that are still in intensive progress and improvement. The algorithms that were presented in this chapter are but a fraction of the existing algorithms in the world, and the reason that we chose to present them is the fact that they are all more or less free to use by the public, and also the fact that they are included in OpenCV by default, under the feature2d module. If you are interested in learning about more algorithms, you can also check out Extra 2D Features Framework (xfeature2d), which contains non-free algorithms such as SURF and SIFT, or other algorithms still in experimental states. Of course, you need to separately download and add them to the OpenCV source code before building them to include their functions in your OpenCV installation. It is also recommended. However, also make sure to try out the algorithms you learned about in this chapter using different...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Computer Vision with OpenCV 3 and Qt5
Published in: Jan 2018Publisher: PacktISBN-13: 9781788472395
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
Amin Ahmadi Tazehkandi

Amin Ahmadi Tazehkandi is an Iranian author, developer, and a computer vision expert.Amin Ahmadi Tazehkandi is an Iranian author, developer, and a computer vision expert. He completed his computer software engineering studies in Iran and has worked for numerous software and industrial companies around the world.
Read more about Amin Ahmadi Tazehkandi