Loading...
You are not logged-in Login/Register





  • Posts   Search Threads
  • l1nuxn3wbieJune 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)July 6, 2009 10:48 AM PDT
    Rate
     
    Re: Displaying video with OpenCV


    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

Forum jump:  

Intel Software Network Forums Statistics

16,369 users have contributed to 46,341 threads and 163,954 posts to date.

In the past 24 hours, we have 18 new thread(s) 102 new posts(s), and 67 new user(s).

In the past 3 days, the most popular thread for everyone has been Formula for the intersection of straight lines The most posts were made to Take a look at John Burkhard&# The post with the most views is \"-check none\" generates error

Please welcome our newest member bikerepair8


For more complete information about compiler optimizations, see our Optimization Notice.