How can i use 'imshow' in double for loop properly?

If I use ‘imshow()’ like below , I can see the screen every 30 frame.
I want to see the screen every frame in using double for loop.
please help me.

for (int i = 0; i < 10000; i++)
{
	for (int j = 0; j < 30; j++)
	{
		cap >> Img;
		cv::imshow("Camera Img", Img);
	}
		
	if (Img.empty())
		break;

	if (cv::waitKey(10) == 27)
	{
		break;
		Img.release();
	}
}

add pollKey after imshow
In imshow loop you can add a boolean (trigger) when pollkey result is 27

I did it… Thank you for your help.

1 Like

I see no sense in this double loop in this example.

Here, pollkey is equivalent to waitkey. the only difference is how much time is spent in the call. in both cases, you must handle the return value. if you do not, you lose key presses.