#include <string.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp> // Video write
#include <sstream>
using namespace std;
class pubimage
{
public:
pubimage()
{
aoutputVideo.open("./demo.avi", CV_FOURCC('M','J','P','G'), 30, cv::Size(544, 960), true);
//文件后缀必须是avi,30是帧数,544*960是图片尺寸
if (aoutputVideo.isOpened()){
for(int i = 1; i < 414; i ++){
string num;
ostringstream convert;
convert << i;
num = convert.str();
cv::Mat img = cv::imread("/media/img/" + num + ".jpg");
aoutputVideo.write(img);
}
}
else
std::cout << "Could not open the output video for write " << std::endl;
}
~pubimage() { }
private:
cv::VideoWriter aoutputVideo;
};
int main(int argc, char** argv){
pubimage pub;
return(0);
}
opencv 把图片序列转化为视频流
猜你喜欢
转载自blog.csdn.net/xiangxianghehe/article/details/80476586
今日推荐
周排行