Forum Jump

Select Group :
Select Forum :
Sorted By :
Sort Order :
From The :
 
Thread Tools  Search this thread 
l1nuxn3wbie
Total Points:
50
Status Points:
0
Green Belt
June 30, 2009 12:11 PM PDT
Displaying video with OpenCV
Hi!
I am trying to play an AVI video using a short program.

// AVI Stream.cpp :
// This program displays an AVI video and performs processing on it
// and thus displays the processed video.
//

#include "stdafx.h"
#include "highgui.h"
#include "cv.h"
#include <iostream>
#include <stdio.h>

using namespace std;


int main(int argc, char** argv)
{
/*IplImage* frame;
int key;

//assert(argc == 2);


CvCapture* capture = cvCaptureFromAVI("music.avi");

if(!capture) return 1;

int framesPerSecond = (int)cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);

cvNamedWindow("Video Example",0);

while(key != 'q'){
frame = cvQueryFrame(capture);

if(!frame) break;

cvShowImage("Video Example",frame);

key = cvWaitKey(1000/framesPerSecond);

}


//frame = cvGrabFrame(capture);
//frame1 = cvRetrieveFrame(capture);
//cvShowImage("Example",frame1);
//while(1)
//{
//frame = cvQueryFrame(capture);
//if(!frame) break;
//cvShowImage("Video Example",frame);
//char c = cvWaitKey(1000);
//if(c == 27) break;
//}

cvReleaseCapture(&capture);
cvDestroyWindow("Video Example");

return 0;*/

cvNamedWindow("Video", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCreateFileCapture("music.avi");

IplImage* frame;
while(1)
{
frame = cvQueryFrame(capture);
if(!frame) break;
cvShowImage("Video",frame);
char c = cvWaitKey(10000000);
if(c == 27) break;


}

//frame = cvQueryFrame(capture);
//cout << "This is what is stored in capture: " << capture;
//cvShowImage("Video",capture);

cvReleaseCapture(&capture);
cvDestroyWindow("Video");
//cout << "This is what is stored in capture: " << capture;

}


Unfortunately, a window displays with the name of the window, but no video plays.  HELP ME PLEASE!!
I don't know if there is a codec I need or what.  The variable that holds my capture structure is 0.










Vladimir Dudnik (Intel)
Total Points:
26,150
Status Points:
26,150
Black Belt
July 6, 2009 10:48 AM PDT
Rate
 
#1

As far as I know, OpenCV uses ffmpeg for video decoding. You may need to ensure that compression format used in your AVI file is supported by ffmpeg.

Vladimir



Intel Software Network Forums Statistics

8285 users have contributed to 31229 threads and 99107 posts to date.
In the past 24 hours, we have 11 new thread(s) 45 new posts(s), and 61 new user(s).

In the past 3 days, the most popular thread for everyone has been comparison cilk++, openmp, pthreads first results The most posts were made to comparison cilk++, openmp, pthreads first results The post with the most views is Very amusing...  Escalated as

Please welcome our newest member tvinni