<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QT 5.2 &#x2F; OpenCV 2.4.8 - Can&#x27;t open video files via VideoCapture]]></title><description><![CDATA[<p dir="auto">Hello Guys!</p>
<p dir="auto">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 dir="auto">PRO- File<br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/qt">@<bdi>QT</bdi></a>       += core gui</p>
<p dir="auto">greaterThan(QT_MAJOR_VERSION, 4): QT += widgets</p>
<p dir="auto">TARGET = videoredux<br />
TEMPLATE = app</p>
<p dir="auto">INCLUDEPATH += C:/OpenCV/opencv_bin/install/include<br />
LIBS += -LC:\OpenCV\opencv_bin\bin <br />
libopencv_core248d <br />
libopencv_highgui248d <br />
libopencv_imgproc248d <br />
libopencv_features2d248d <br />
libopencv_calib3d248d <br />
libopencv_video248d \</p>
<p dir="auto">SOURCES += main.cpp<br />
mainwindow.cpp</p>
<p dir="auto">HEADERS  += mainwindow.h</p>
<p dir="auto">FORMS    += mainwindow.ui@</p>
<p dir="auto">and the MainWindow Class:<br />
@#include "mainwindow.h"<br />
#include "ui_mainwindow.h"<br />
#include &lt;QFileDialog&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;qdebug.h&gt;<br />
#include &lt;opencv2/core/core.hpp&gt;<br />
#include &lt;opencv2/highgui/highgui.hpp&gt;<br />
#include &lt;opencv2/imgproc/imgproc.hpp&gt;<br />
#include &lt;opencv/cv.h&gt;</p>
<p dir="auto">MainWindow::MainWindow(QWidget *parent) :<br />
QMainWindow(parent),<br />
ui(new Ui::MainWindow)<br />
{<br />
ui-&gt;setupUi(this);<br />
ui-&gt;videoStatusLabel-&gt;setText("Kein Video geladen.");</p>
<pre><code>// SIGNALS &amp; SLOTS

QObject::connect(ui-&gt;chooseVideoButton,SIGNAL(clicked()),
                 this,SLOT(chooseVideo()));
QObject::connect(ui-&gt;startButton,SIGNAL(clicked()),
                 this,SLOT(startProcess()));
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void MainWindow::chooseVideo(){</p>
<pre><code>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);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void MainWindow::startProcess(){<br />
QString videoPath = ui-&gt;videoStatusLabel-&gt;text();<br />
QFileInfo video(videoPath);<br />
if(video.exists()){<br />
const std::string path = videoPath.toUtf8().constData();<br />
cv::VideoCapture capture(path);<br />
cv::Mat frame;</p>
<pre><code>    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 dir="auto">}@</p>
<p dir="auto">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. Does anyone know how to solve this problem?</p>
<p dir="auto">Thank you very much!</p>
<p dir="auto">Nadine</p>
]]></description><link>https://forum.qt.io/topic/36128/qt-5-2-opencv-2-4-8-can-t-open-video-files-via-videocapture</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 03:03:34 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/36128.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Jan 2014 19:25:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QT 5.2 &#x2F; OpenCV 2.4.8 - Can&#x27;t open video files via VideoCapture on Thu, 02 Jan 2014 22:19:24 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I would say that the path you give to OpenCV is invalid. Qt uses Unix style path internally on all platforms but not OpenCV.</p>
<p dir="auto">Use QDir::toNativeSeparators and it should work better.</p>
]]></description><link>https://forum.qt.io/post/209247</link><guid isPermaLink="true">https://forum.qt.io/post/209247</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 02 Jan 2014 22:19:24 GMT</pubDate></item></channel></rss>