我在 ubuntu 17.04 中使用opencv 320 并简单地尝试计算 java 中给定视频的总帧数。这是我的代码。
public class VideoAnalysis {
public static void main (String [] args){
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
File f = new File("/home/aritra/workspace/oopencv/horror.mp4");
boolean b = f.exists();
System.out.println(b);
VideoCapture capture = new VideoCapture("/home/aritra/workspace/oopencv/horror.mp4");
if(!capture.isOpened()){
System.out.println("could not open this file ");
}
else{
System.out.println("length"+(capture.get(Videoio.CAP_PROP_FRAME_COUNT)));
}
}
}
我已将视频文件保留在项目中。每当我运行此程序时,它都会显示消息
true
Failed to query video capabilities: Inappropriate ioctl for device
libv4l2: error getting capabilities: Inappropriate ioctl for device
VIDEOIO ERROR: V4L: device /home/aritra/workspace/oopencv/horror.mp4: Unable to query number of channels
could not open this file
但我的视频 I/O 状态是
Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: NO
-- FFMPEG: YES
-- avcodec: YES (ver 57.64.101)
-- avformat: YES (ver 57.56.101)
-- avutil: YES (ver 55.34.101)
-- swscale: YES (ver 4.2.100)
-- avresample: YES (ver 3.1.0)
-- GStreamer: NO
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- OpenNI2: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- Aravis SDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: Using libv4l1 (ver 1.12.3) / libv4l2 (ver 1.12.3)
-- XIMEA: NO
-- Xine: NO
-- gPhoto2: NO
我已经检查了OpenCV Constants.CaptureProperty并根据https://github.com/opencv/opencv/issues/6157使WITH_LIBV4L=ON但仍然收到这些消息。我应该怎么办?谁能帮我?