// 参考资料:(建议先阅读此处)
// http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/ml/introduction_to_svm/introduction_to_svm.html#introductiontosvms
// https://docs.opencv.org/3.4/d1/d73/tutorial_introduction_to_svm.html
// http://blog.sina.com.cn/s/blog_662c7859010105za.html
// https://blog.csdn.net/xingkongfenqi/article/details/49794567
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/ml.hpp>
int main()
{
// 给训练数据打上标签,对应1类和-1类
int Labels[4] = {
1, -1, -1, -1 };
cv::Mat LabelsMat(4, 1, CV_32SC1, Labels); // CV_32SC1: 32位有符号单通道矩阵
// 设置训练数据的坐标,注意要和前面的Labels对应起来
float TrainingData[4][2] = {
{
501., 10.}, {
255., 10.}, {
501., 255.}, {
10., 501.} };
cv::Mat TrainingDataMat
[OpenCV3.4.3] SVM使用教程
最新推荐文章于 2023-03-23 13:54:47 发布