How to write a sequence as images as a avi video ?
Hi, I want to create a video using a sequence as images, I have greayscale images with resolution 640x480,I tried to make this simple application fallowing the next steps: 1) I read each images with imread 2) I used VideoWriter for writing video, but my video after saving is the 0 second saved :(
This is my code:
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
for(int i = 0; i < 30; i++)
{
char left[1024] = "";
sprintf(left, "left640x480_%d.bmp", i);
Mat image(640, 480, CV_8UC1);
image = imread(left, 0);
VideoWriter video("out.avi", CV_FOURCC('M','J','P','G'), 30, Size(640, 480), false);
Mat frame;
image.copyTo(frame);
video.write(frame);
imshow( "Frame", frame );
char c = (char)waitKey(33);
if( c == 27 )
break;
}
return 0;
}
I use OpenCV 3.1 in C++. Thank you for your help!
I changed what you said, but the result is the same @berak