#include"..\match2\videoWriterFFmpeg.h"
#include<iostream>
using namespace std;
string toString(int a)
{
char str[10];
sprintf(str, "%d", a);
return string(str);
}
int main()
{
videoWriterFFmpeg videoWriter;
Mat src;
string img_name = "F:\\testdata_M2_DF\\error\\PIC_20171209155440787_629\\";
string video_path = "F:\\out.mp4";
int bitrate = 4500000;
int fps = 24;
if (videoWriter.open((char *)video_path.c_str(), bitrate, fps, 4000,3000) != 0)
cout << "error" << endl;
for (int i = 0; i < 4; i++)
{
src = imread(img_name + toString(i) + ".JPG");
for (int j = 0; j < 20; j++)
{
cout << "write frame " <<i*20+j+1 << " sucess" << endl;
videoWriter.write(src);
}
}
videoWriter.flush();
return 0;
}
///******************************/
///* 立体匹配和测距 */
///******************************/
//
//#include <opencv2/opencv.hpp>
//#include <iostream>
//
//using namespace std;
//using namespace cv;
//
//const int imageWidth = 1600; //摄像头的分辨率
//const int imageHeight = 1200;
//Size imageSize = Size(imageWidth, imageHeight);
//
//Mat rgbImageL, grayImageL;
//Mat rgbImageR, grayImageR;
//Mat rectifyImageL, rectifyImageR;
//
//Rect validROIL;//图像校正之后,会对图像进行裁剪,这里的validROI就是指裁剪之后的区域
//Rect validROIR;
//
//Mat mapLx, mapLy, mapRx, mapRy; //映射表
//Mat Rl, Rr, Pl, Pr, Q; //校正旋转矩阵R,投影矩阵P 重投影矩阵Q
//Mat xyz; //三维坐标
//
//Point origin; //鼠标按下的起始点
//Rect selection; //定义矩形选框
//bool selectObject = false; //是否选择对象
//
//int blockSize = 0, uniquenessRatio = 0, numDisparities = 0;
//Ptr<StereoBM> bm = StereoBM::create(16, 9);
//
///*
//事先标定好的相机的参数
//fx 0 cx
//0 fy cy
//0 0 1
//*/
//Mat cameraMatrixL = (Mat_<double>(3, 3) << 1.3326580049539741e+03, 0., 8.5707693143813731e+02, 0.,
// 1.3328103465314075e+03, 5.8864510013773088e+02, 0., 0., 1.);
////对应matlab里的左相机标定矩阵
//Mat distCoeffL = (Mat_<double>(5, 1) << -2.8045130586483613e-01, 2.3793216045311979e-02,
// 1.2707455545866691e-03, -8.5396571769118861e-05,
// 1.5333351218494151e-01);
////对应Matlab所得左i相机畸变参数
//
//Mat cameraMatrixR = (Mat_<double>(3, 3) << 1.3415015304155293e+03, 0., 8.2015522358224712e+02, 0.,
// 1.3405584983867755e+03, 6.2602260787344244e+02, 0., 0., 1.);
////对应matlab里的右相机标定矩阵
//
//Mat distCoeffR = (Mat_<double>(5, 1) << -2.9689673143127382e-01, 1.4135067565749787e-01,
// -5.2500364253100303e-04, -5.9239444589348561e-06,
// -5.2601323055946496e-02);
////对应Matlab所得右相机畸变参数
//
//Mat T = (Mat_<double>(3, 1) << 6.5772611841823936e-001, -1.0384210259014603e+001,
// -4.3222483571379522e+000);//T平移向量
// //对应Matlab所得T参数
////Mat rec = (Mat_<double>(3, 1) << -0.00306, -0.03207, 0.00206);//rec旋转向量,对应matlab om参数
//Mat R=(Mat_<double>(3,3)<< 9.9992653287053390e-001, -6.5184724487311113e-003,
// 1.0219509697052322e-002, 6.5049975997708192e-003,
// 9.9997792935128083e-001, 1.3512277941784086e-003,
// -1.0228092086992024e-002, -1.2846506373009731e-003,
// 9.9994686649091513e-001);//R 旋转矩阵
//
//
// /*****立体匹配*****/
//void stereo_match(int, void*)
//{
// bm->setBlockSize(2 * blockSize + 5); //SAD窗口大小,5~21之间为宜
// bm->setROI1(validROIL);
// bm->setROI2(validROIR);
// bm->setPreFilterCap(31);
// bm->setMinDisparity(0); //最小视差,默认值为0, 可以是负值,int型
// bm->setNumDisparities(numDisparities * 16 + 16);//视差窗口,即最大视差值与最小视差值之差,窗口大小必须是16的整数倍,int型
// bm->setTextureThreshold(10);
// bm->setUniquenessRatio(uniquenessRatio);//uniquenessRatio主要可以防止误匹配
// bm->setSpeckleWindowSize(100);
// bm->setSpeckleRange(32);
// bm->setDisp12MaxDiff(-1);
// Mat disp, disp8;
// bm->compute(rectifyImageL, rectifyImageR, disp);//输入图像必须为灰度图
// disp.convertTo(disp8, CV_8U, 255 / ((numDisparities * 16 + 16)*16.));//计算出的视差是CV_16S格式
// reprojectImageTo3D(disp, xyz, Q, true); //在实际求距离时,ReprojectTo3D出来的X / W, Y / W, Z / W都要乘以16(也就是W除以16),才能得到正确的三维坐标信息。
// xyz = xyz * 16;
// imshow("disparity", disp8);
//}
//
///*****描述:鼠标操作回调*****/
//static void onMouse(int event, int x, int y, int, void*)
//{
// if (selectObject)
// {
// selection.x = MIN(x, origin.x);
// selection.y = MIN(y, origin.y);
// selection.width = std::abs(x - origin.x);
// selection.height = std::abs(y - origin.y);
// }
//
// switch (event)
// {
// case EVENT_LBUTTONDOWN: //鼠标左按钮按下的事件
// origin = Point(x, y);
// selection = Rect(x, y, 0, 0);
// selectObject = true;
// cout << origin << "in world coordinate is: " << xyz.at<Vec3f>(origin) << endl;
// break;
// case EVENT_LBUTTONUP: //鼠标左按钮释放的事件
// selectObject = false;
// if (selection.width > 0 && selection.height > 0)
// break;
// }
//}
//
//Mat scaleMat(Mat src, Size sz)
//{
// Size src_sz = src.size();
// if (src_sz == sz)
// return src;
// Mat dst;
// float scale = min(float(src_sz.height) / sz.height, float(src_sz.width) / sz.width);
// resize(src, dst, Size(), 1.0 / scale, 1.0 / scale);
// return dst(Rect(0, 0, sz.width, sz.height));
//}
//
///*****主函数*****/
//int main()
//{
// /*
// 立体校正
// */
// //Rodrigues(rec, R); //Rodrigues变换
// stereoRectify(cameraMatrixL, distCoeffL, cameraMatrixR, distCoeffR, imageSize, R, T, Rl, Rr, Pl, Pr, Q, 0,
// 0, imageSize, &validROIL, &validROIR);
// initUndistortRectifyMap(cameraMatrixL, distCoeffL, Rl, Pr, imageSize, CV_32FC1, mapLx, mapLy);
// initUndistortRectifyMap(cameraMatrixR, distCoeffR, Rr, Pr, imageSize, CV_32FC1, mapRx, mapRy);
//
// /*
// 读取图片
// */
//
// rgbImageL = imread("../calib/13m1/13.bmp", CV_LOAD_IMAGE_COLOR);
// cvtColor(rgbImageL, grayImageL, CV_BGR2GRAY);
// rgbImageR = imread("../calib/2m1/2.bmp", CV_LOAD_IMAGE_COLOR);
// cvtColor(rgbImageR, grayImageR, CV_BGR2GRAY);
// Size imgSize = Size(1600, 1200);
// rgbImageL = scaleMat(rgbImageL, imgSize);
// rgbImageR = scaleMat(rgbImageR, imgSize);
// imshow("ImageL Before Rectify", grayImageL);
// imshow("ImageR Before Rectify", grayImageR);
//
// /*
// 经过remap之后,左右相机的图像已经共面并且行对准了
// */
// remap(grayImageL, rectifyImageL, mapLx, mapLy, INTER_LINEAR);
// remap(grayImageR, rectifyImageR, mapRx, mapRy, INTER_LINEAR);
//
// /*
// 把校正结果显示出来
// */
// Mat rgbRectifyImageL, rgbRectifyImageR;
// cvtColor(rectifyImageL, rgbRectifyImageL, CV_GRAY2BGR); //伪彩色图
// cvtColor(rectifyImageR, rgbRectifyImageR, CV_GRAY2BGR);
// resize(rgbRectifyImageL, rgbRectifyImageL, Size(), 0.25, 0.25);
// resize(rgbRectifyImageR, rgbRectifyImageR, Size(), 0.25, 0.25);
// //单独显示
// //rectangle(rgbRectifyImageL, validROIL, Scalar(0, 0, 255), 3, 8);
// //rectangle(rgbRectifyImageR, validROIR, Scalar(0, 0, 255), 3, 8);
// imshow("ImageL After Rectify", rgbRectifyImageL);
// imshow("ImageR After Rectify", rgbRectifyImageR);
//
// //显示在同一张图上
// Mat canvas;
// double sf;
// int w, h;
// sf = 600. / MAX(imageSize.width, imageSize.height);
// w = cvRound(imageSize.width * sf);
// h = cvRound(imageSize.height * sf);
// canvas.create(h, w * 2, CV_8UC3); //注意通道
//
// //左图像画到画布上
// Mat canvasPart = canvas(Rect(w * 0, 0, w, h)); //得到画布的一部分
// resize(rgbRectifyImageL, canvasPart, canvasPart.size(), 0, 0, INTER_AREA); //把图像缩放到跟canvasPart一样大小
// Rect vroiL(cvRound(validROIL.x*sf), cvRound(validROIL.y*sf), //获得被截取的区域
// cvRound(validROIL.width*sf), cvRound(validROIL.height*sf));
// //rectangle(canvasPart, vroiL, Scalar(0, 0, 255), 3, 8); //画上一个矩形
// cout << "Painted ImageL" << endl;
//
// //右图像画到画布上
// canvasPart = canv
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
opencv+ffmpeg图片序列写mp4.zip (66个子文件)
opencv+ffmpeg图片序列写mp4
.vs
stero_match
v14
.suo 32KB
match2
Release
vc140.pdb 1.85MB
match2.Build.CppClean.log 128B
match2.log 3KB
match.obj 3.45MB
match2.tlog
CL.write.1.tlog 264B
CL.read.1.tlog 41KB
unsuccessfulbuild 0B
CL.command.1.tlog 664B
link.write.1.tlog 2B
match2.lastbuildstate 196B
link.command.1.tlog 2B
link.read.1.tlog 2B
match2.vcxproj.filters 1KB
videoWriterFFmpeg.h 2KB
x64
Release
vc140.pdb 1.89MB
match2.Build.CppClean.log 975B
match2.log 2KB
match.obj 3.49MB
match2.tlog
CL.write.1.tlog 636B
CL.read.1.tlog 81KB
CL.command.1.tlog 2KB
match2.write.1u.tlog 608B
link.write.1.tlog 1KB
match2.lastbuildstate 209B
link.command.1.tlog 4KB
link.read.1.tlog 10KB
match.cpp 6KB
match2.vcxproj 12KB
match2.vcxproj.user 406B
stero_match.VC.db 21.29MB
x64
Release
calib2.lib 2KB
match2.lib 4KB
calib2.iobj 449KB
match2.iobj 341KB
calib2.pdb 2.04MB
match2.dll 27KB
match2.exp 2KB
calib2.ipdb 508KB
calib2.exp 1007B
match2.ipdb 139KB
match2.pdb 1.95MB
calib2.exe 30KB
calib2
calib2.vcxproj.user 406B
Release
calib2.tlog
unsuccessfulbuild 0B
CL.command.1.tlog 2B
calib2.lastbuildstate 196B
vc140.pdb 36KB
calib2.log 187B
calib2.vcxproj 8KB
match2.lib 4KB
x64
Release
calib2.tlog
CL.write.1.tlog 644B
CL.read.1.tlog 81KB
CL.command.1.tlog 1KB
link.write.1.tlog 1KB
calib2.lastbuildstate 209B
link.command.1.tlog 3KB
link.read.1.tlog 9KB
calib2.write.1u.tlog 2KB
calib2.Build.CppClean.log 685B
vc140.pdb 1.89MB
calib2.log 2KB
calib2.obj 3.48MB
calib2.vcxproj.filters 947B
calib2.cpp 9KB
stero_match.sln 3KB
共 66 条
- 1
资源评论
- u0100719352019-06-20资源可以用
- Edgar_U2019-06-26等待验证,希望有效
alpc40
- 粉丝: 70
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功