When I run the following code, images are saved and I can see them and that they are what I want in the directory, but the calls to display them bring up a cascade of 20 windows, none of which contain the images I want to load; all the windows are just grey.
for(int i = 1; i <= 20; i++)
{
img = cvQueryFrame(capture);
num = intToString(i);
fname = base + num + jpg;
winName = base + num;
cvSaveImage( fname.c_str(), img );
//img = cvLoadImage(fname.c_str(), -1);
cvNamedWindow(winName.c_str(), CV_WINDOW_AUTOSIZE);
cvMoveWindow(winName.c_str(), 15*i, 15*i); //cascade windows
cvShowImage(winName.c_str(), img);
}
The line that I have commented out is where I’ve tried reloading the image after saving it, but I still get the same results. Anyone know what my issue is?
I solved this problem by calling
cvWaitKey(). From the docs: Note: This function is the only method in HighGUI that can fetch and handle events, so it needs to be called periodically for normal event processing