调用opencv中BP神经网络来对图像进行分类

/*调用BP进行图像分类只需:
img0=cvLoadImage("099.pbm",0);
BPClassifier bp_cly;//初始化对象.
number=bp_cly.classify(img0);*/
 
 
 
 

#include 
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


你可能感兴趣的:(opencv)