我很想通过OpenCV Java捕获IP摄像机视频流。但我得到了这个警告:
警告:打开文件时出错 (../../模块/ highgui / SRC / cap_ffmpeg_impl.hpp:537)
我试过了this solution。但它没有用。
我在Windows 10上使用openCV 2.4.11。 我的设置是:
我加载了库:C:\ opencv2411 \ opencv \ build \ java \ opencv-2411.jar
Java库路径: -Djava.library.path = “C:\ opencv2411 \的OpenCV \构建\ java中\ x64的” C:\ opencv2411 \ opencv \ build \ x64 \ vc12 \ bin和 C:\ opencv2411 \ opencv \ sources \ 3rdparty \ ffmpeg被添加到PATH
package opencvApp;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
import org.opencv.highgui.VideoCapture;
public class OpencvApp{
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
VideoCapture cap=new VideoCapture();
cap.set(Highgui.CV_CAP_PROP_FRAME_WIDTH,640);
cap.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT,360);
cap.open("C:\\Users\\Berkan\\Videos\\vidm1453499924.mp4");
//cap.open(0);
Mat foto = new Mat();
if (cap.isOpened())
{
System.out.println("Video is opened");
cap.read(foto);
Highgui.imwrite("C:\\Users\\Berkan\\Desktop\\ada\\foto.png", foto);
cap.release();
}
else
{
System.out.println("Fail");
}
}
}