#include<sstream>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <cassert>
#include <cmath>
#include <fstream>
#include <time.h>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/types_c.h"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/video/tracking.hpp"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/calib3d/calib3d.hpp"
using namespace std;
using namespace cv;
int main(int argc, char **argv)
{
VideoCapture cap("test2.mp4");
assert(cap.isOpened());
cap>>prev;
VideoWriter outputVideo;
if (!outputVideo.isOpened())outputVideo.open("compare.mp4" , CV_FOURCC('X','V','I','D'), 24,cvSize(cur.rows, cur.cols*2+10), true);
outputVideo<< prev;
while(true) {
stringstream ss;
string name = "cropped_";
string type = ".jpg";
ss<<name<<(chk)<<type;
string filename = ss.str();
ss.str("");
imwrite(filename, canvas);
outputVideo<< canvas;
prev = cur.clone();//cur.copyTo(prev);
prev_ref = cur_ref.clone();//cur.copyTo(prev);
cur_grey.copyTo(prev_grey);
cout << "Frame: " << k << "/" << max_frames << " - good optical flow: " << prev_corner2.size() << endl;
k++;
}
问题:这是我的代码的一个小描述。现在我尝试编写我的画布(OpenCV中的Mat类型的变量)来创建视频。它给出了一个错误。即使我尝试了。 avi文件或.mp4文件它不会写/创建视频。请帮我。它显示错误&#34; [mp4 @ 0xa0aac0]标签XVID / 0x44495658与输出编解码器ID&#39; 13&不兼容#39;错误&#34;。我正在使用带有intel core processor-i5的ubuntu 14.04