【发布时间】:2014-04-24 19:09:08
【问题描述】:
我有一系列灰度图像,例如名为 fr1.jpg, fr2.jpg,…
我用这段代码从这个序列中写了一个视频。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include "opencv2/opencv.hpp"
#include<string.h>
using namespace cv;
using namespace std;
int main()
{
//Read sequence of images
Size frameSize(1360,1024);
cout<<path<<endl;
VideoCapture sequence("path/fr%1d.jpg");
if (!sequence.isOpened())
{
cerr << "Failed to open Image Sequence!\n" << endl;
return -1;
}
//Write video
VideoWriter oVideoWriter ("path/MyVideo.avi",CV_FOURCC('8','B','P','S'), 30, frameSize);
Mat imageGrey;
if(!oVideoWriter.isOpened())
{
cout<<"ERROR: Failed to write the video"<<endl;
return -1;
}
Mat Image;
do
{
sequence>>Image;
printf("Write image to video \n");
Mat imageArr[] = {Image, Image, Image};
merge(imageArr, 3, imageGrey);
//cvtColor(Image,imageGrey,CV_GRAY2BGR);
oVideoWriter.write(imageGrey);
}while(!Image.empty());
return 1;
}
我收到了这个错误
OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /path/modules/core/src/matrix.cpp, line 697
libc++abi.dylib: terminate called throwing an exception
The program has unexpectedly finished.
【问题讨论】:
-
我解决了这个问题
标签: image opencv video-capture