C++ 使用opencv通过文件存储进行保存时出错

C++ 使用opencv通过文件存储进行保存时出错,c++,opencv,image-processing,computer-vision,svm,C++,Opencv,Image Processing,Computer Vision,Svm,我正试图从BOW算法中保存词汇表。下面是我的代码 FileStorage fs; fs.open("Vocabulary.xml", FileStorage::WRITE); Mat vocabulary = bow.cluster(); fs << vocabulary ; fs.release(); FileStorage fs2; fs2.open("Vocabulary.xml", FileStorage::READ); fs2 ["Vocabulary"] >

我正试图从BOW算法中保存词汇表。下面是我的代码

FileStorage fs; 
fs.open("Vocabulary.xml", FileStorage::WRITE); 
Mat vocabulary = bow.cluster(); 
fs << vocabulary ;
fs.release();
FileStorage fs2; 
fs2.open("Vocabulary.xml", FileStorage::READ); 
fs2 ["Vocabulary"] >> vocabulary ;
dextract.setVocabulary(vocabulary);

cv::Mat training_mat(num_img , dictionarySize,CV_32FC1);
cv::Mat labels(num_img,1,CV_32FC1);

CvSVM svm;
svm.load( "trainsvm.xml" );

如果没有在文件中设置词汇表的名称,请尝试以下操作:

fs << "Vocabulary" << vocabulary ;
fs
fs << "Vocabulary" << vocabulary ;