视频读取打标记后视频保存

打标记后视频保存

VideoCapture cap(“D:\rec.avi”);
//计算视频帧数
int VedioFPS = cap.get(CV_CAP_PROP_FPS);
//cout << “视频帧率” << VedioFPS << endl;
// 保存视频
VideoWriter writer(“alarm.mp4”, CV_FOURCC(‘M’, ‘J’, ‘P’, ‘G’), VedioFPS, Size(ROI_Weidth, ROI_Height * 2));
if (!cap.isOpened())
{
cout << “Error opening video stream or file” << endl;
return -1;
}
Mat frame;
while (1) {
// Capture frame-by-frame
cap >> frame;
// If the frame is empty, break immediately
if (frame.empty()) break;
if (frame.channels() == 3) cvtColor(frame, frame, CV_RGB2GRAY);
//******************
// 处理图像
//******************
//在图像上打上标记
cvtColor(frame(roi_rect), ROIimg, CV_GRAY2RGB);
std::string str2 = “OriginalImage”;
cv::putText(ROIimg, str2, Point(roi_rect.width *0.5 - 20, 20), cv::FONT_HERSHEY_SIMPLEX, 0.3, cv::Scalar(0, 255, 255), 1);
cv::putText(ROIimg, “Load”, Point(0, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 255, 255), 1);
std::string str1 = “ImageProcessing”;
cv::putText(tempImg, str1, Point(roi_rect.width *0.5 - 30, 20), cv::FONT_HERSHEY_SIMPLEX, 0.3, cv::Scalar(0, 255, 255), 1);
vconcat(ROIimg, tempImg, conbine);
imshow(“Image”, conbine);
writer << conbine;
char c = (char)waitKey(1);
if (c == 27)
break;
}
cap.release();
destroyAllWindows();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值