title: having cv2.imread reading images from file objects or memory-stream-like data (here non-extracted tar)
body: <p>I have a <code>.tar</code> file containing several hundreds of pictures (<code>.png</code>). I need to process them via opencv. </p>
  
  <p>I am wondering whether - for efficiency reasons - it is possible to process them without passing by the disc. In other, words I want to read the pictures from the memory stream related to the tar file.</p>
  
  <p>Consider for instance</p>
  
  <pre><code> import tarfile
   import cv2
  
   tar0 = tarfile.open('mytar.tar')
   im = cv2.imread( tar0.extractfile('fname.png').read() )
  </code></pre>
  
  <p>The last line doesn't work as <code>imread</code> expects a file name rather than a stream.</p>
  
  <p>Consider that this way of reading directly from the <code>tar</code> stream can be achieved e.g. for text (see e.g. <a href="https://stackoverflow.com/q/8858414/1714661">this SO question</a>).</p>
  
  <hr>
  
  <p>Any suggestion to open the stream with the correct <code>png</code> encoding?</p>
  
  <p>Untarring to ramdisk is of course an option, although I was looking for something more <em>cachable</em>.</p>