First of all, I use C++. I have a CV_32F cv::Mat and when I write it down to disk using FileStorage, the size of this Mat becomes around 4.5 times higher than the size of it when it was on RAM during the program execution. I do some experiments and each time it is like that. So, when I tried to read it again, obviously my RAM(6 GB) becomes insufficient ,though it was not during the program execution.
Here is how I write it down to the disk:
FileStorage fs( PATH, FileStorage::WRITE);
fs << "concatMat" << concatMat;
fs.release();
And this is how I calculate the occupied RAM size during the program execution:
size_t sz= sizeof( concatMat) + concatMat.total()*sizeof( CV_32F);
I wonder the reason behind this, especially why there is always 4.5 times difference?
EDIT: I save them with .bin extension, not YAML or XML. I need to save them efficiently and can take recommendations.