当我在函数中使用:'x'.write(frame)写入opencv中的视频文件时,程序传递代码并且我没有错误地编译它,但是当我打开文件时,我看到它是0kb,播放器无法播放它。 有人可以帮我吗?为什么函数'x'.write(frame)对我不起作用?
这里我的代码:
// Setup output video
cv::VideoWriter output_cap("output.avi",
CV_CAP_PROP_FOURCC,
CV_CAP_PROP_FPS,
cv::Size(1376, 768));
// Loop to read frames from the image and write it to the output capture
cv::Mat frame = imread("1.jpg", 0);
for(int hgf=1;hgf<=300;hgf++)
{
if (!frame.data)
{
break;
}
output_cap.write(frame);
}
好日子大家!
检查此:[** OpenCV VideoWriter不会写任何**](http://stackoverflow.com/questions/12054907/opencv-videowriter-wont-write-anything-although-cvwritetoavi-does) –
我怀疑打开文件“1.jpg”失败,所以没有什么可写的。从确保它正确打开开始。 – molbdnilo
它是开放的“1.JPG”我检查了它。 –