vishesh999 / Silent_learner

0 stars 0 forks source link

Making Frames of a Video #2

Closed vishesh999 closed 6 years ago

vishesh999 commented 6 years ago

include <opencv/cv.h>

include <opencv/highgui.h>

include

include

include

include

include

include

include

include

include

include

include

IplImage image = 0; IplImage prev_image = 0; CvCapture* capture = 0;

int show = 1;

int main( int argc, char** argv ) { int frameNum = 0;

char* video = argv[1];
capture = cvCreateFileCapture(video);

if( !capture ) { 
    printf( "Could not initialize capturing..\n" );
    return -1;
}

if( show == 1 )
    cvNamedWindow( "Video", 0 );

while( true ) {
    IplImage* frame = 0;
    int i, j, c;

    // get a new frame
    frame = cvQueryFrame( capture );
    if( !frame )
        break;

    if( !image ) {
        image =  cvCreateImage( cvSize(frame->width,frame->height), 8, 3 );
        image->origin = frame->origin;
    }

    cvCopy( frame, image, 0 );

    if( show == 1 ) {
        cvShowImage( "Video", image);
        c = cvWaitKey(3);
        if((char)c == 27) break;
    }

    std::cerr << "el frame lol " << frameNum << "-th frame" << std::endl;
    frameNum++;
}

if( show == 1 )
    cvDestroyWindow("Video");

return 0;

}

I studied this code and i am not clear about the opencv commands used in this program . Please can someone help me understand these commands or can refer me to a link where I can study about these commands.

Thankyou!