- Machine Learning for OpenCV
- Michael Beyeler
- 415字
- 2021-07-02 19:47:21
Having a look at supervised learning in OpenCV
Knowing how supervised learning works is pretty if we can't put it into practice. Thankfully, OpenCV provides a pretty straightforward interface for all its statistical learning models, which includes all supervised learning models.
In OpenCV, every machine learning model derives from the cv::ml::StatModel base class. This is fancy talk for saying that if we want to be a machine learning model in OpenCV, we have to provide all the functionality that StatModel tells us to. This includes a method to train the model (called train) and a method to measure the performance of the model (called calcError).
Thanks to this organization of the software, setting up a machine learning model in OpenCV always follows the same logic:
- Initialization: We call the model by name to create an empty instance of the model.
- Set parameters: If the model needs some parameters, we can set them via setter methods, which can be different for every model. For example, in order for a k-NN algorithm to work, we need to specify its open parameter, k (as we will find out later).
- Train the model: Every model must provide a method called train, used to fit the model to some data.
- Predict new labels: Every model must provide a method called predict, used to predict the labels of new data.
- Score the model: Every model must provide a method called calcError, used to measure performance. This calculation might be different for every model.
As we will make the occasional use of scikit-learn to implement some machine learning algorithms that OpenCV does not provide, it is worth pointing out that learning algorithms in scikit-learn follow an almost identical logic. The most notable difference is that scikit-learn sets all the required model parameters in the initialization step. In addition, it calls the training function fit instead of train, and the scoring function score instead of calcError.
- iOS 9 Game Development Essentials
- 數據結構(Java語言描述)
- 名師講壇:Java微服務架構實戰(SpringBoot+SpringCloud+Docker+RabbitMQ)
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Android程序設計基礎
- Web Development with MongoDB and Node(Third Edition)
- Building Machine Learning Systems with Python(Second Edition)
- 一塊面包板玩轉Arduino編程
- C#程序設計(項目教學版)
- C指針原理揭秘:基于底層實現機制
- 測試架構師修煉之道:從測試工程師到測試架構師
- 深入分析GCC
- Scratch編程從入門到精通
- 少兒編程輕松學(全2冊)
- Building Clouds with Windows Azure Pack