title: Python-opencv: Read image data from stdin
body: <p>How can I read image data from stdin rather than from a file?</p>
  
  <p>With the C++ interface, it seems to be possible: <a href="https://stackoverflow.com/a/5458035/908515">https://stackoverflow.com/a/5458035/908515</a>. The function <code>imdecode</code> is available in Python as well. But it expects a <code>numpy array</code> as (first) argument. I have no idea how to convert the stdin data.</p>
  
  <p>This is what I tried:</p>
  
  <pre><code>import cv
  import sys
  import numpy
  
  stdin = sys.stdin.read()
  im = cv.imdecode(numpy.asarray(stdin), 0)
  </code></pre>
  
  <p>Result: <code>TypeError: &lt;unknown&gt; data type = 18 is not supported</code></p>