title: OpenCV C++ Video Capture does not seem to work
body: <p>I am using a Mac OS X 10.6 machine. I have OpenCV 2.1 x64 compiled from source using Xcode and its GCC compiler.</p>
  
  <p>I am having trouble using the C++ video reading features of OpenCV. Here is the simple test code I am using (came straight from OpenCV documentation):</p>
  
  <pre><code>#include "cv.h"
  #include "highgui.h"
  
  using namespace cv;
  
  int main(int, char**)
  {
      VideoCapture cap(0); // open the default camera
      if(!cap.isOpened())  // check if we succeeded
          return -1;
  
      Mat edges;
      namedWindow("edges",1);
      for(;;)
      {
          Mat frame;
          cap &gt;&gt; frame; // get a new frame from camera
          cvtColor(frame, edges, CV_BGR2GRAY);
          GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
          Canny(edges, edges, 0, 30, 3);
          imshow("edges", edges);
          if(waitKey(200) &gt;= 0) break;
      }
      // the camera will be deinitialized automatically in VideoCapture destructor
      return 0;
  }
  </code></pre>
  
  <p>The program compiles fine, but when I try to run it, I see the green light on my webcam come on for a few seconds, then the program exits with the error message:</p>
  
  <pre><code>OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /Users/mark/Downloads/OpenCV-2.1.0/src/cxcore/cxarray.cpp, line 2476
  terminate called after throwing an instance of 'cv::Exception'
    what():  /Users/mark/Downloads/OpenCV-2.1.0/src/cxcore/cxarray.cpp:2476: error: (-206) Unrecognized or unsupported array type in function cvGetMat
  </code></pre>
  
  <p>Under debug mode, the matrix still seems to be empty after the cap >> frame line. </p>
  
  <p>I get similar behavior when I try to capture from a video file or an image, so it's not the camera. What is wrong, do you think? Anything I can do to make this work? </p>
  
  <p>EDIT: I'd like to add that if I use the C features, everything works fine. But I would like to stick with C++ if I can. </p>
  
  <p>Thanks</p>