title: Convert ndarray stored to a binary file created with cPickle to cv::Mat in C++
body: <p>I have a <a href="http://www.numpy.org/" rel="nofollow">numpy</a> <code>ndarray</code> holding <code>numpy.float64</code> data stored to a file in binary format using <a href="https://docs.python.org/2/library/pickle.html" rel="nofollow">cPickle's</a> <code>dump()</code> method.</p>
  
  <pre><code>from cPickle import dump, HIGHEST_PROTOCOL
  with open(filePath, 'wb') as f:
      dump(numpyArray, f, protocol=HIGHEST_PROTOCOL)
  </code></pre>
  
  <p>At the time of this writing, <code>HIGHEST_PROTOCOL</code> uses cPickle's <a href="https://docs.python.org/2/library/pickle.html#data-stream-format" rel="nofollow">protocol version 2</a> but there doesn't seem to be much documentation on how exactly this protocol works.</p>
  
  <p>What I'm trying to do is read this file and create a <code>cv::Mat</code> object (<a href="http://docs.opencv.org/modules/core/doc/basic_structures.html#mat" rel="nofollow">see here</a>) with the data, which is proving quite difficult to do.</p>
  
  <p>At this point, I'm looking to get things working as quickly as possible and I am not too worried about performance, storage space and efficiency. However, these factors might become important later.</p>
  
  <p>Thus, my question would be, what is the easiest way I can go about converting the data in this file into a <code>cv::Mat</code> object? If you think that the easiest way isn't necessarily the most efficient way then I would love to hear your thoughts on that as well. Note that I'm open to using a different storage format, possibly just a text file, if it will make interoperability between Python and C++ easier.</p>
  
  <p>I have to store the <code>numpy</code> array to disk because I need to be able to open and read this file on a mobile device (iOS and Android) and using a network call to get the data is not really on the table at the moment.</p>