VideoWriter videoWriter = new VideoWriter(outputFile, fourCC.toInt(), videoCapture.get(Videoio.CAP_PROP_FPS),
frameSize, true);
此返回的帧大小为0
答案 0 :(得分:1)
解决方案首先,您尝试打开视频并检查是否成功打开,如下所示:
VideoCapture capture = new VideoCapture(filePath);
if(!capture.isOpened()) {
System.out.println("Cannot open the video.");
return;
}
如果没有返回,则表示已成功打开,现在您已阅读框架并显示或至少检查框架的高度和宽度,如下所示:
Mat frame = new Frame();
capture.read(frame);
int width = (int) capture.get(Videoio.CAP_PROP_FRAME_WIDTH);
int height = (int) capture.get(Videoio.CAP_PROP_FRAME_HEIGHT);
System.out.println("width = " + width );
System.out.println("height = " + height);
如果一切顺利,那就没关系,您可以使用capture
并阅读相框,如果不能正常工作,请转到OpenCV
解压缩的文件夹并复制此行
C:\opencv\build\x64\vc14\bin
到Environment Variable
并重新启动电脑,然后重试。