OpenCV: change resolution of VideoCapture while it is capturing
<p>I am using OpenCV 3.1.0 on Windows 10 64-bit. I would like to be able to set the resolution of webcam while webcam still working. It's easy to set resolution after camera working. But I can't set resolution when webcam is capturing. </p>

<p>Here is my code:</p>

<pre><code>cv::VideoCapture cap(0);
cap.set(cv::CAP_PROP_FRAME_WIDTH, 0x7FFFFFFF);          // working
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 0x7FFFFFFF);         // working

while (true) {
    cv::Mat frame;
    cap &gt;&gt; frame;
    if (!frame.data) continue;
    cv::imshow("test", frame);
    if (cv::waitKey(1) &gt;= 0) break;

    int newHeight = 500 + rand() % 4 * 100;
    cap.set(cv::CAP_PROP_FRAME_HEIGHT, newHeight);      // not working
}

int newHeight = 500 + rand() % 4 * 100;
cap.set(cv::CAP_PROP_FRAME_HEIGHT, newHeight);          // not working
</code></pre>