我想保存我的分类器,然后当我试图读回它时,它会引发分段错误。我试图弄清楚,我认为这是opencv的一个错误。
这是我的代码:
bool result = model.train(samples,Mat(),ps,&lables);
printf("Train Result %d\n",result);
CvFileStorage *fs;
fs = cvOpenFileStorage("skin_new.xml",NULL, CV_STORAGE_WRITE);
model.write_params(fs);
cvReleaseFileStorage( &fs );
CvFileStorage *fs1;
//Reading back XML file
fs1 = cvOpenFileStorage("skin_new.xml",NULL , CV_STORAGE_READ);
classifier.read_params(fs1,NULL);
cvReleaseFileStorage( &fs1 );
printf("XML reading done\n");
//the two dominating colors
Mat means = model.getMeans();//This step leads to segmentation error
我正在使用 OpenCV 2.3.1。