如何修复cvCreateFileCapture()错误:无法创建摄像机捕获

时间:2019-04-23 11:32:53

标签: java video-streaming javacv

我从youtube教程中获得了有关通过Java将IP摄像机连接到笔记本电脑的代码,但是当我运行该程序时,出现以下错误:

  

线程“主”中的异常   com.googlecode.javacv.FrameGrabber $ Exception:cvCreateFileCapture()   错误:无法创建摄像机捕获。在   com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:171)     在app.JavaCv.main(JavaCv.java:16)处警告:打开文件时出错   (../../ modules / highgui / src / cap_ffmpeg_impl.hpp:537)

我的手机和RTSP Camera Server上都有IP网络摄像头,但我认为我没有正确使用IP或格式。另外,如果有人可以解释这里发生的事情,我将不胜感激。

这是我的代码:

package app;

import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.OpenCVFrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.IplImage;

public class JavaCv {

    public static void main(String[] args) throws Exception {
        OpenCVFrameGrabber frameGrabber = new OpenCVFrameGrabber("http://<Local IP>:8080/playlist.m3u"); 
        // http://<Local IP>:8080/playlist.m3u for RTSP Camera Server and
        // http://<Local IP>:8080/ for IP Webcam (that's what I used based on the streaming app)

        frameGrabber.setFormat("mjpg");
        frameGrabber.start();

        IplImage iPimg = frameGrabber.grab();

        CanvasFrame canvasFrame = new CanvasFrame("Camera");
        canvasFrame.setCanvasSize(iPimg.width(), iPimg.height());

        while (canvasFrame.isVisible() && (iPimg = frameGrabber.grab()) != null) {
            canvasFrame.showImage(iPimg);
        }
        frameGrabber.stop();
        canvasFrame.dispose();
        System.exit(0);
    }
}

可以找到here的所有资源的youtube视频。

还尝试了here中的实现。 但是没有结果。

0 个答案:

没有答案