title: OpenCV: How to store descriptors in a file?
body: <p>I want to detect an object in an image using features from OpenCV. I have some images containing that kind of objects. I search the KeyPoints in them and store the descriptors of the ones inside the contour of the object. Based on those descriptors I want to do the matching between them and the descriptors of KeyPoints from an image that may, or may not contain the object.</p>
  
  <p>My <strong>problem</strong> is that for some cases (eg. ORB) the descriptors are of type CV_8U and for others (eg. SIFT) they are CV_32F. If I want to store them in a file and if I do:</p>
  
  <pre><code>fileStream &lt;&lt; descriptors.ptr&lt;uchar&gt;(rowIdx)[colIdx] &lt;&lt; ";";
  </code></pre>
  
  <p>the CV_32F ones are not ok (but there is no error) and most of them are <code>255</code>. And if I do:</p>
  
  <pre><code>fileStream &lt;&lt; descriptors.ptr&lt;float&gt;(rowIdx)[colIdx] &lt;&lt; ";";
  </code></pre>
  
  <p>the CV_8U ones are stored as <code>4.00897e-07</code> or <code>5.14004e+19</code>, that is also not ok.</p>
  
  <p>How do you suggest me to do it? If you know some better way to do the whole problem, please tell me.</p>