通过opencv我们可以轻松的计算图像的特征向量,然后搭建svm向量机,去进行图像识别,不过,svm向量机,opencv也自带了哈哈。
#include<cv.h>
#include<highgui.h>
#include <iostream>
#include "opencv2/opencv.hpp"
#include <math.h>
using namespace std;
using namespace cv;
int stop;
void gaosi(double goas[3][3])
{
double sum = 0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
int X = i - 1;
int Y = j - 1;
goas[i][j] = (1 / (2 * (3.14)*pow(1.5, 2)))*exp(-(X*X + Y*Y) / (2 * pow(1.5, 2)));
sum += goas[i][j];
cout << goas[i][j] << " ";
}
cout << endl;
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
goas[i][j] /= sum;
}
}
}
template <class Type,class type> type max(Type a,type b)
{