AHF
AHF

Reputation: 1072

Getting error while saving through Filestorage using opencv

I am trying to save the vocabulary from the BOW algorithm. Below is my code.

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" );

Here is my error :

OpenCV Error: Unspecified error (No element name has been given) in unknown function , file c:\opencv\2.4.4\build\include\opencv2\core\operations.hpp , line 2908

Upvotes: 4

Views: 3642

Answers (1)

Michele mpp Marostica
Michele mpp Marostica

Reputation: 2472

You aren't setting the name of your vocabulary in the file, try this:

fs << "Vocabulary" << vocabulary ;

Upvotes: 6

Related Questions