Hello,
I am trying to capture a video stream from a webcam, and simultaneously display the frames, using OpenCV. Previously, I have captured one image, and then at the end of my program displayed the image in a window, which works fine. However, when I try to capture a sequence of several images, and display them in the window, then the window just turns grey, rather than displaying the image. Only at the end of the program will it display an image - not in the middle of the program. Below is the code I am using:
int main()
{
CvCapture* capture = cvCaptureFromCAM(0);
IplImage* image;
cvNamedWindow("Window");
while (true)
{
cvGrabFrame(capture);
image = cvRetrieveFrame(capture);
cvShowImage("Window", image);
}
return 0;
}
The window is simply grey the whole time, rather than updating the image as I want it to. It can show an image, but only once the while loop is completed, and the program reaches its return line. But I want it to show the images simultaneously as I capture them, such that I get a video displayed in real-time.
Any ideas?
Thanks.