Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QT OpenCV Video is not playing

    General and Desktop
    2
    4
    1270
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aniljoby last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • A
          aniljoby last edited by

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

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • First post
              Last post