Chapter 21. StatModel: The Standard Model for Learning in OpenCV

In the previous chapter we discussed machine learning broadly and looked at just a few basic algorithms that were implemented in the library long ago. In this chapter we will look at several more modern techniques that will prove to be of very wide application. Before we start on those, however, we will introduce cv::ml::StatModel, which forms the basis of the implementation for the interfaces to all of the more advanced algorithms we will see in this chapter. Once armed with an understanding of cv::ml::StatModel, we will spend the remainder of the chapter looking at various learning algorithms available in the OpenCV library. The algorithms are presented here in an approximately chronological order relative to their introduction into the computer vision community.1

Common Routines in the ML Library

The contemporary routines in the ML library are implemented within classes that are derived from the common base class cv::ml::StatModel. This base class defines the interface methods that are universal to all of the available algorithms. Some of the methods are declared in the base class cv::Algorithm, from which cv::ml::StatModel itself is derived. Here is the (somewhat abbreviated) cv::ml::StatModel base class definition straight from the machine learning (ML) library:

 // Somewhere above... // namespace cv { // namespace ml { class StatModel : public cv::Algorithm { public: /** Predict options */ enum Flags { UPDATE_MODEL ...

Get Learning OpenCV 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.