title: OpenCV load image/video from stdin
body: <p>I am trying to read a jpg image from stdin using the following code:</p>
  
  <pre><code>int c,count=0;
  vector&lt;uchar&gt; buffer; //buffer for coding
  
  /* for stdin, we need to read in the entire stream until EOF */
  while ((c = fgetc(stdin)) != EOF) {
       buffer.push_back(c);
   count++;
  }
  
  
  cout &lt;&lt; "Bytes: " &lt;&lt; count &lt;&lt; endl;
  Mat im = imdecode(Mat(buffer),CV_LOAD_IMAGE_COLOR);
  cout &lt;&lt; "Decoded\n";
  namedWindow("image", CV_WINDOW_AUTOSIZE);
  imshow("image",im);
  
  cv::waitKey(0);
  </code></pre>
  
  <p>I run this in cmd:</p>
  
  <pre><code>OpenCVTest &lt; thumb.jpg
  </code></pre>
  
  <p>This is what I get:</p>
  
  <pre><code>Bytes: 335
  Decoded
  OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in unknown function, file ..\..\..\src\opencv\modules\core\src\array.cpp, line 2482
  </code></pre>
  
  <p>The error seems reasonable since the image is about 7 KB and but according to the counter only 335 bytes have been read.</p>
  
  <p>What am I doing wrong ?</p>
  
  <p>My ultimate goal is to read a video from stdin frame by frame. Would that be possible ?</p>
  
  <p>Thank you very much !</p>