title: Qt 5.2 / OpenCV 2.4.8 - Can’t open video files via VideoCapture
body: <p>I have a big problem that i can’t solve by myself. OpenCV itself works fine, but i’m not able to load videos. Here’s my code:</p>
  
  <p>PRO- File</p>
  
  <pre><code>QT       += core gui
  
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  
  TARGET = videoredux
  TEMPLATE = app
  
  INCLUDEPATH += C:/OpenCV/opencv_bin/install/include
  LIBS += -LC:\\OpenCV\\opencv_bin\\bin \
      libopencv_core248d \
      libopencv_highgui248d \
      libopencv_imgproc248d \
      libopencv_features2d248d \
      libopencv_calib3d248d \
      libopencv_video248d \
  
  
  SOURCES += main.cpp\
          mainwindow.cpp
  
  HEADERS  += mainwindow.h
  
  FORMS    += mainwindow.ui
  </code></pre>
  
  <p>and the MainWindow Class:</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;QFileDialog&gt;
  #include &lt;iostream&gt;
  #include &lt;qdebug.h&gt;
  #include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;opencv2/imgproc/imgproc.hpp&gt;
  #include &lt;opencv/cv.h&gt;
  
  
  MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      ui-&gt;videoStatusLabel-&gt;setText("Kein Video geladen.");
  
      // SIGNALS &amp; SLOTS
  
      QObject::connect(ui-&gt;chooseVideoButton,SIGNAL(clicked()),
                   this,SLOT(chooseVideo()));
      QObject::connect(ui-&gt;startButton,SIGNAL(clicked()),
                   this,SLOT(startProcess()));
  
  }
  
  void MainWindow::chooseVideo(){
  
      QString fileName = QFileDialog::getOpenFileName(this,
           tr("Open Video"), "/home", tr("Video Files (*.avi *.mp4 *.mpeg *.mpg)"));
      qDebug() &lt;&lt; "Path:" &lt;&lt; fileName;
      ui-&gt;videoStatusLabel-&gt;setText(fileName);
  }
  
  void MainWindow::startProcess(){
      QString videoPath = ui-&gt;videoStatusLabel-&gt;text();
      QFileInfo video(videoPath);
      if(video.exists()){
          const std::string path = videoPath.toUtf8().constData();
          cv::VideoCapture capture(path);
          cv::Mat frame;
  
          if(!capture.isOpened()){
              qDebug() &lt;&lt; "Error, video not loaded";
          }
  
          cv::namedWindow("window",1);
          while(true)
          {
              bool success = capture.read(frame);
              if(success == false){
                  break;
              }
              cv::imshow("window",frame);
              cv::waitKey(20);
          }
          cv::waitKey(0);
      }
      else{
          qDebug() &lt;&lt; "Error, File doesn't exist";
      }
  }
  </code></pre>
  
  <p>The paths are correct, I tried many different video formats but he never loads the videos. I’m running Qt on a Windows 8 machine and i have “K-Lite Codec Pack 10.2.0 Basic” and ffmpeg installed. The videos are playing properly with my video players. I also tried to copy the .dll to the working directory, searched for opencv dll's in the system32 directory and rebuild OpenCV with mingw on this computer. I know that many people have the same problems, but none of their suggestions solved it. Does anyone know how to solve this problem?</p>
  
  <p>Thank you very much!</p>
  
  <p>Nadine</p>
  
  <p>----UPDATE---- I still can't open video files, so I programmed the application on a Windows7 64-Bit system. It worked fine, but when I try to open the application on a Windows8 computer it still can't open the file. It doesn't matter which codecs are installed, because it generally runs on every Windows7 computer and fails on every Windows8 computer.. The same for older OpenCV-Versions. Is there a general problem with OpenCV and Windows8? </p>