grab and save specific frame from camera in opencv c++
<p>I have program in opencv with c++
I want to save specific frame from sequence of frames but just last frame is saved!
let me introduce better
I have the following code :</p>

<pre><code>   Mat frame,img1,img2;
   for(int i = 0; i &lt; 100; i++)
        {
            cout&lt;&lt;i&lt;&lt;endl;
            waitKey(1);
            video &gt;&gt; frame;

            if (i==10)
                {
                    img2=frame;

                }
            namedWindow("img");
            imshow("img",frame);
        }

namedWindow("pic");
imshow("pic",img2);
waitKey(30);
video.release();
waitKey(0);  
</code></pre>

<p>as you can see 100 frames are grabbed and I want to save tenth frame in img2  and show it  out of for loop when loop is finished 
but the problem here is that it does not show tenth frame! indeed it shows last frame!  </p>