Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT OpenCV Video is not playing
QtWS25 Last Chance

QT OpenCV Video is not playing

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.4k Views
  • 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 Offline
    A Offline
    aniljoby
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • A Offline
        A Offline
        aniljoby
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved