网站建设系统开发,百度站长平台官网死链提交,中山市做网站专业的,海报设计制作平台问题描述#xff1a;
如题 问题原因#xff1a;
其实就是保存的帧如果处理成灰度图#xff08;单通道#xff09;的话#xff0c;保存为新视频#xff0c;则新视频读取不了 解决办法#xff1a;
处理成三通道#xff0c;保存的新视频即可被读取 代码#xff1a; Vi…问题描述
如题 问题原因
其实就是保存的帧如果处理成灰度图单通道的话保存为新视频则新视频读取不了 解决办法
处理成三通道保存的新视频即可被读取 代码 VideoCapture inputVideo(/home/jason/work/01-img/红外/test.mp4);int width static_castint(inputVideo.get(CAP_PROP_FRAME_WIDTH));int height static_castint(inputVideo.get(CAP_PROP_FRAME_HEIGHT));double fps inputVideo.get(cv::CAP_PROP_FPS);VideoWriter outputVideo(/home/jason/work/01-img/红外/test_DDE.mp4,VideoWriter::fourcc(m, p, 4, v),double(1000/fps),cv::Size(width, height));Mat frame, result;while (true){inputVideo frame;if (frame.empty())break;cv::cvtColor(frame, frame, cv::COLOR_BGR2GRAY);DDE(frame, result);cv::cvtColor(result, result, cv::COLOR_GRAY2BGR);// 必须转为3通道否则保存的新视频读取不了outputVideo.write(result);imshow(input, frame);imshow(output, result);if (waitKey(30) q)break;}inputVideo.release();outputVideo.release();