APPEND to xml.gz

asked 2013-11-13 15:39:56 -0600

slaw gravatar image

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

//Append conversion map to XML, cv::FileStorage::APPEND);
fs << "strings" << "[";
for(iter=ss2Int.begin(); iter != ss2Int.end(); iter++){
  fs << static_cast<std::ostringstream*>( &(std::stringstream() << iter->second) )->str();
  fs << iter->first;
fs << "]";

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)?


edit retag flag offensive close merge delete