I am trying to convert a bunch of images into a video, I got OpenCV code working perfectly fine on the Windows machine but videos I make on windows machine doesn't seem to work on pi using opencv. So I thought I'll just run the same code on pi and encode the images on the pi itself. The issue that I am getting is seems that OpenCV can't detect a single video codec.
Here is my code:
Code: Select all
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
const int totalImages = 180;
const char* depthDatasetPath("W:/Tsukuba/groundtruth/disparity_maps/right");
string filename = "W:/Tsukuba/videos/test3.avi";
//int codec = CV_FOURCC('F', 'M', 'P', '4'); // use MP4 as video codec
VideoWriter writer(filename, -1, 30, Size(640, 480), true); // -1 show menu to choose codec
for (int i = 1; i < totalImages; i++)
{
Mat img = cv::imread(format("%s/tsukuba_disparity_R_%05d.png", depthDatasetPath, i), CV_LOAD_IMAGE_GRAYSCALE);
writer.write(img);
if (waitKey(1) >= 0)
break;
}
writer.release();
}Thanks