用于iplimage的Javacv :: MPEG_2视频

时间:2014-02-13 15:18:05

标签: javacv

我正在使用电视摄像头和TV_TO_USB设备在我的labtop上获取视频

我希望在javacv程序中使用视频

由于一些问题,我无法立即将视频送到程序中(尽管它适用于内部和外部网络摄像头),计算机崩溃并显示蓝屏

所以我尝试使用USB附带的软件开始录制和保存视频,这样做有效,然后在录制时将录制的视频录制到我的javacv程序中

它有效,但几秒后,它会停止并显示以下错误

OpenCV Error: Assertion failed (src.type() == dst.type()) in cvResize, file ..\..\..\..\opencv\modules\imgproc\src\imgwarp.cpp, line 3927
Exception in thread "main" java.lang.RuntimeException: ..\..\..\..\opencv\modules\imgproc\src\imgwarp.cpp:3927: error: (-215) src.type() == dst.type() in function cvResize

    at com.googlecode.javacv.cpp.opencv_imgproc.cvResize(Native Method)
    at com.googlecode.javacv.cpp.opencv_imgproc.cvResize(opencv_imgproc.java:736)
    at returnToWork.ReturnToWork.main(ReturnToWork.java:174)
java.awt.Point[x=917,y=30]

VIDEOINPUT SPY MODE

SETUP: Looking For Capture Devices
SETUP: 0) CyberLink Webcam Splitter 
SETUP: 1) HP Webcam-50 
SETUP: 2) USB TV Device 
SETUP: 3 Device(s) found

[mpeg2video @ 0000000000238400] ac-tex damaged at 1 4
[mpeg2video @ 0000000000238400] Warning MVs not available

代码是: -

public static void main(String[] args) throws Exception {


    IplImage img ;

    CvCapture capture3 = cvCreateFileCapture("02_13_17_05_10.mpeg");
    final Vector v = new Vector<>() ;
    Image i  ;
    ImageIcon ic;
    JPA j1 ;
    if(!capture3.isNull())
    {
    img = cvQueryFrame(capture3);
    i = img.getBufferedImage();
    ic= new ImageIcon(i);
    j1 = new JPA(ic ,933,700);
    JFrame jf = new JFrame();
    jf.setTitle("HE");
    jf.setSize(j1.getWidth(), j1.getHeight());
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jf.addMouseListener(new ForMouse());

    for(;;)
    {

        img = cvQueryFrame(capture3);


        IplImage image = IplImage.create(933, 700, 8, 3);
        //resize the image
         cvResize(img,image);
        i = image.getBufferedImage();
        ic= new ImageIcon(i);

        j1.jl.setIcon(ic);
        j1.add(j1.jl);
        jf.add(j1);
        jf.validate();




        char c = (char) cvWaitKey(15);

        if (c=='q')break;

    }
    }
}
}

1 个答案:

答案 0 :(得分:0)

嗯..

我发现问题并且它已经解决了..问题是“cvWaitKey(毫秒)函数没有工作(可能它只适用于cvnamedwindow),所以我的程序的帧速率大于录制的视频通过相机..问题解决了我使用Thread.sleep(30);而不是