VideoWriter videoWriter = new VideoWriter(outputFile, fourCC.toInt(), videoCapture.get(Videoio.CAP_PROP_FPS),
frameSize, true);
这个返回框架尺寸为0OpenCV的:VideoCapture ::得到(CV_CAP_PROP_FPS)返回0 FPS直接视频输入,而不在Java中使用相机
VideoWriter videoWriter = new VideoWriter(outputFile, fourCC.toInt(), videoCapture.get(Videoio.CAP_PROP_FPS),
frameSize, true);
这个返回框架尺寸为0OpenCV的:VideoCapture ::得到(CV_CAP_PROP_FPS)返回0 FPS直接视频输入,而不在Java中使用相机
解决方案起初试图打开该视频,并检查是否打开成功如下:
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);
如果一切顺利的话,这是OK,你可以使用capture
和读取镜架,如果不工作,去你OpenCV
提取文件夹,此行
C:\opencv\build\x64\vc14\bin
复制到您的Environment Variable
并重新启动你的电脑,然后再试一次。
我试试这个,但视频未打开,也设置路径环境变量 –
我使用32位系统,所以我设置C:\ opencv \ build \ x64 \ vc12 \ bin –
根据您的系统设置路径,如果是32,则使用正确的路径,如果您没有正确设置路径,则在OpenCV 3中,视频可能无法打开。 –
请帮忙。我试图在视频中运动检测,对于那个使用github代码,但是输出是 –
在你的代码中是什么'frameSize,true);' –
final Size frameSize = new Size((int)videoCapture.get (Videoio.CAP_PROP_FRAME_WIDTH), \t \t \t \t(int)videoCapture.get(Videoio.CAP_PROP_FRAME_HEIGHT)); \t \t logger.log(Level.INFO,String.format(“Resolution:%s”,frameSize)); –