title: How to save CV_32F type CV::Mat to a file without loosing precision?
body: <p>I'm using cv::PCA class for a face recognition project. I convert photos of faces to one row vectors, concatenate them to one big array and feed to pca, to acquire a new space in which I can try to use distance for recognition. Problem is, that calculating the pca from scratch each time I start the program is really time consuming (almost five minutes). I figured out that I need to save the calculated pca to hard drive, and load it when I start the program again. And here is the problem. As I can see, all cv::Mat objects in cv::PCA are of type CV_32F. When i try to save it as a normal picture, its converted to 8 bit image, and there is some data lost. When i use XML/YAML persistence, the generated file is really big, and data is also lost (I have saved it, loaded to another structure and ran <code>cerr&lt;&lt;sum(pca_orginal.mean==pca_loaded.mean)[0]&lt;&lt;endl</code> to check how big is the difference). Right now I'm trying to use <code>std::ofstream::write</code> with <code>std::ofstream::binary</code> flag, and <code>istream::read</code>, but there are some type issues (<code>out.write(_pca.mean.data,_pca.mean.rows*_pca.mean.cols*4/*CV_32F-&gt;4*CV_8U*/\);</code> generates <code>error: no matching function for call to ‘std::basic_ofstream&lt;char, std::char_traits&lt;char&gt; &gt;::write(uchar*&amp;, int)</code>. I've also heard about openexr library and it's file format, but I would rather avoid using additional libraries. I'm using OpenCV 2.3.1 and OpenCV 2.2.</p>
  
  <p><strong>edit</strong>:
  I'm sorry for the confusion. I misread <code>cv::Mat operator==</code> description, and thought that it works the opposite way that it does, so <code>sum(pca_orginal.mean==pca_loaded.mean)[0]</code> giving 0 is the worse possible result, not the best. It means that XML/YML works fine apart from generating huge files. Also, after using c-style casting I was able to make the binary streams work, but the files generated are also big (over 150MB).</p>