title: Capturing 1080p at 30fps from logitech c920 with openCV 2.4.3
body: <p>I'm trying to capture the video stream off of my Logitech C920 in OpenCV.  With Labview I can access an MJPG stream at 30fps 1080p.  In opencv I am limited to either 5fps or 640x480.</p>
  
  <p>Here is the code relevant to the camera settings:</p>
  
  <pre><code>this-&gt;camRef.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
  this-&gt;camRef.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);
  this-&gt;camRef.set(CV_CAP_PROP_FOURCC,CV_FOURCC('M','J','P','G'));
  </code></pre>
  
  <p>These all return 1, yet I get a 5fps stream of 1080p which corresponds to the YUY2 stream.<br>
  If I add the following line:</p>
  
  <pre><code>this-&gt;camRef.set(CV_CAP_PROP_FPS, 30);
  </code></pre>
  
  <p>This returns 0.
  I get a 30 fps stream at 640x480.  To me it looks like the MJPG setting isn't be accepted but I don't know what to do or how to fix that.</p>
  
  <p>EDIT:  The following crashes the program.</p>
  
  <pre><code> this-&gt;camRef.read(this-&gt;image);
   std::cout&lt;&lt; this-&gt;camRef.get(CV_CAP_PROP_FOURCC)                            &lt;&lt; std::endl;
   std::cout&lt;&lt; this-&gt;camRef.set(CV_CAP_PROP_FRAME_WIDTH, config.width)         &lt;&lt; std::endl;
   std::cout&lt;&lt; this-&gt;camRef.set(CV_CAP_PROP_FRAME_HEIGHT, config.height)       &lt;&lt; std::endl;
   std::cout&lt;&lt; this-&gt;camRef.set(CV_CAP_PROP_FOURCC,CV_FOURCC('M','J','P','G')) &lt;&lt; std::endl;
   std::cout&lt;&lt; this-&gt;camRef.get(CV_CAP_PROP_FOURCC)                            &lt;&lt; std::endl;
  </code></pre>
  
  <p>Then in my run code I have the following:</p>
  
  <pre><code>void camera::run()
  {
      while(true)
      {
          if(this-&gt;camRef.read(this-&gt;image) == 0)
          {
             if(this-&gt;capture)
              {
                  cv::imwrite(fileName,this-&gt;image);
                  this-&gt;count++;
              }
          }
          msleep(15);
      }
  }
  </code></pre>
  
  <p>EDIT2: Solution is to set the fourCC codec before setting camera height and width.</p>