QT OpenCV Video is not playing



  • I am on the way to develop a hand gesture controlled robot. But for processing i can't open any video files. The code used for the video is
    @
    #include <QCoreApplication>
    #include <opencv/highgui.h>
    #include <opencv2/imgproc/imgproc.hpp>
    #include <stdio.h>
    #include <iostream>
    #include <opencv2/opencv.hpp>
    #include <opencv/cv.h>
    #include <opencv2/video/video.hpp>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

     Mat src_gray,src;
    

    namedWindow( "Source",0 );

    VideoCapture cap( "hand.MP4");

    if(!cap.isOpened()){
        cout<<"not open";
        return a.exec&#40;&#41;;
    }
    
    while(1) {
    
    cap.read(src);
    .....................
    

    //processing codes here..
    ....................
    imshow( "Source", src );

    if(waitKey(30==27))
            break;
    

    }

    return a.exec&#40;&#41;;
    

    }

    }

    @

    But every time output is "not open";
    Can you please suggest whats gone wrong in my code.
    I am using windows 8.1, opencv 2.4.9, QT 5.2.1.
    Thanks.


  • Lifetime Qt Champion

    Hi,

    "hand.MP4" is a relative path, so my guess is that the file is not found. Where is hand.MP4 located ?



  • The file is stored in its build directory.
    Also i tried giving the complete path, but no use.


  • Lifetime Qt Champion

    Then you might be having a codec problem. Search for "opencv mp4", you'll get some useful hints to go further


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.