private static String path1 = "D:\\soft\\opencv\\opencv4.5\\build\\x64\\vc15\\bin\\opencv_world455.dll";
private static String path2 = "D:\\soft\\opencv\\opencv4.5\\build\\bin\\opencv_videoio_ffmpeg455_64.dll";
public static void main(String[] args) {
//必须要加入这两个东西,在opencv的安装目录下可以找到这两个文件
System.load(path1);
System.load(path2);
VideoCapture cap = new VideoCapture("rtsp://10.73.130.119:8854/live");
while(cap.isOpened()){
boolean flag;
Mat image = new Mat();
flag = cap.read(image);
if(!flag){
System.out.println("--- not able to get image ---");
break;
}
HighGui.imshow("video", image);
HighGui.waitKey(10);
}
System.out.println("--- video capture closed ---");
}
console
[ERROR:0@32.270] global C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap.cpp (166) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.5.5) C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): rtsp://10.73.130.119:8854/live in function ‘cv::icvExtractPattern’
— video capture closed —
Disconnected from the target VM, address: ‘127.0.0.1:54345’, transport: ‘socket’