Building your own estimator
In this book, we visited a whole variety of machine learning tools and algorithms that OpenCV provides straight out of the box. And if, for some reason, OpenCV does not provide exactly what we are looking for, we can always fall back on scikit-learn.
However, when tackling more advanced problems, you might find yourself wanting to perform some very specific data processing that neither OpenCV nor scikit-learn provide, or you might want to make slight adjustments to an existing algorithm. In this case, you may want to create your own estimator.
Writing your own OpenCV-based classifier in C++
Since OpenCV is one of those Python libraries that does not contain a single line of Python code under the hood (I'm kidding, but it's close), you will have to implement your custom estimator in C++. This can be done in four steps:
- Implement a C++ source file that contains the main source code. You need to include two header files, one that contains all core functionality of OpenCV...