Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to convert sequence of images in to video?

Hello all, i want to convert sequence of images into video. i written the code it is not giving any error but the created .avi file is only 5.51 kb and nothing is playing with it. my code is

include "opencv2/opencv.hpp"

include <sstream>

include <iostream>

include "stdafx.h"

using namespace cv; using namespace std;

Mat frame, img; int i = 0;

int main(int, char**) {

Size frame_size(256, 256);


//Size frame_size(frame_width, frame_height);
int frames_per_second = 30;

//Create and initialize the VideoWriter object 

VideoWriter oVideoWriter("BIKINGSub.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'),
    frames_per_second, frame_size, true);

int z = 1;
char filename[80];


while (1)
{


    sprintf_s(filename, "SubtractionResultsStatic/BIKING/biking_%d.png", z);
    Mat frame = imread(filename, 1);


    //If the VideoWriter object is not initialized successfully, exit the program




    //resize(frame, frame, Size(320, 180));



    oVideoWriter.write(frame); //writer the frame into the file

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if (waitKey(10) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }

    z++;
}



printf("\ndone\n");
return 0;

} please suggest what i'm doing wrong?

click to hide/show revision 2
None

updated 2019-01-03 09:40:25 -0600

berak gravatar image

how to convert sequence of images in to video?

Hello all, i want to convert sequence of images into video. i written the code it is not giving any error but the created .avi file is only 5.51 kb and nothing is playing with it. my code is

include "opencv2/opencv.hpp"

include <sstream>

include <iostream>

include "stdafx.h"

#include "opencv2/opencv.hpp"
#include <sstream>
#include <iostream>
#include "stdafx.h"




using namespace cv;
using namespace std;

std; Mat frame, img; int i = 0;

0; int main(int, char**) {

{


    Size frame_size(256, 256);


 //Size frame_size(frame_width, frame_height);
 int frames_per_second = 30;

 //Create and initialize the VideoWriter object 

 VideoWriter oVideoWriter("BIKINGSub.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'),
     frames_per_second, frame_size, true);

 int z = 1;
 char filename[80];


 while (1)
 {


     sprintf_s(filename, "SubtractionResultsStatic/BIKING/biking_%d.png", z);
     Mat frame = imread(filename, 1);


     //If the VideoWriter object is not initialized successfully, exit the program




     //resize(frame, frame, Size(320, 180));



     oVideoWriter.write(frame); //writer the frame into the file

     imshow("MyVideo", frame); //show the frame in "MyVideo" window

     if (waitKey(10) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
     {
         cout << "esc key is pressed by user" << endl;
         break;
     }

     z++;
 }



 printf("\ndone\n");
 return 0;
}

} please suggest what i'm doing wrong?