/*调用BP进行图像分类只需:
img0=cvLoadImage("099.pbm",0);
BPClassifier bp_cly;//初始化对象.
number=bp_cly.classify(img0);*/
#include <ml.h>
CvANN_MLP BP; //opencv中的BP
//构造函数
BPClassifier:: BPClassifier ()
{
//initial
//sprintf(file_path , "../OCR/");
sprintf(file_path , "C:\\Users\\y450\\Desktop\\recognize\\OCR\\");
train_samples = 80;
classes= 10;
size=40;
trainData = cvCreateMat(train_samples*classes, size*size, CV_32FC1);
trainClasses = cvCreateMat(train_samples*classes, 10, CV_32FC1);
neuralLayers=cvCreateMat(3,1,CV_32SC1);
sampleWts=cvCreateMat(train_samples*classes,1,CV_32FC1);
for (int i=0;i<train_samples*classes;i++)
{
cvSet1D(sampleWts,i,cvScalar(1));
}
cvSet1D(neuralLayers,0,cvScalar(size*size));
cvSet1D(neuralLayers,1,cvScalar(5));
cvSet1D(neural
调用opencv中BP神经网络来对图像进行分类
最新推荐文章于 2022-10-17 15:32:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)