APPEND to xml.gz
Hi OpenCV Community,
I have saved a predictor from the randomtrees class as a ".xml.gz" file. Then I try appending something to the end of the file:
//Save predictor as XML
forest->save(xmlfile);
//Append conversion map to XML
fs.open(xmlfile, cv::FileStorage::APPEND);
ss2Int=dat->get_class_labels_map();
fs << "strings" << "[";
for(iter=ss2Int.begin(); iter != ss2Int.end(); iter++){
fs << static_cast<std::ostringstream*>( &(std::stringstream() << iter->second) )->str();
fs << iter->first;
}
fs << "]";
fs.release();
Due to the extension of the file, I am getting the following runtime exception:
OpenCV/opencv-2.4.6/modules/core/src/persistence.cpp:2733: error: (-213) Appending data to compressed file is not implemented in function cvOpenFileStorage
Of course, this problem goes away when I only use files that end in ".xml" rather than ".xml.gz". However, the tradeoff is a big difference in file size (over 100 MB for the ".xml" file and only ~7.1 MB for the ".xml.gz" compressed file).
Can anybody offer a good way to resolve this within C++ (I know that I could compress it after the xml file is created but it would be sub-optimal)?
Sean