| Thread Tools | Search this thread |
|---|
l1nuxn3wbie
| 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. | |||||
|
|||||||||||||
| 8442 users have contributed to 31547 threads and 100370 posts to date. |
|---|
| In the past 24 hours, we have 11 new thread(s) 31 new posts(s), and 42 new user(s). In the past 3 days, the most popular thread for everyone has been /fpp interferes with breakpoints/stepping through code - again The most posts were made to Help with hitting maximum record length in the compiler with debug info? The post with the most views is Blue and pink diamonds? Ve Please welcome our newest member mrnm |