I Am trying to write an application which transmits video and then playing it. But for start I Am trying to just open video and play it and I am having troubles with that.
Here is my code:
VideoPlayer::Play()
{
CvCapture *capture = cvCreateFileCapture(m_FileName.c_str());
IplImage* frame = cvQueryFrame(capture);
int frame_number = 0;
cvNamedWindow("stream_server", CV_WINDOW_AUTOSIZE);
while (true)
{
if (!frame)
{
std::cout << "Failed\n";
break;
}
cvShowImage("stream_server", frame);
++frame_number;
frame = cvQueryFrame(capture);
}
cvReleaseCapture(&capture);
}
Thing is – when I run this program, I see videoWindows appears but it shows grey screen and hangs with sand clock.
Can you please help me with that?
You need to call
waitKeyin order for the window to be updated. This will stop if the user presses the letter ‘c’: