adding openCV Video to QT Widget
-
wrote on 18 Dec 2016, 21:22 last edited by
Hey Folks,
Having a bit of an issue getting a video to display in a QT Widget.
I can get an openCV window to run/function and display video from my webcam just fine,but when I execute a program the openCV window is the only part the will open until I terminate the webcam loop. Once the webcam is disabled my QT GUI will pop up like normal.
Below is a copy of my VideoCapture example and a part of my MainWindow Class.
void VideoHeader::videoCap() { Mat frame; VideoCapture cap; cap.open(0); if(!cap.isOpened()) { cerr << "ERROR! Unable to open camera\n"; } cout << "Start grabbing" << endl; for(;;) { cap.read(frame); if(frame.empty()) { cerr << "ERROR! Blank frame grabbed\n"; break; } //convertMat(frame); //imshow("Live", frame); /* if(waitKey(5) >= 0) break; */ } }```
MainWindow::MainWindow() : textEdit(new QTextEdit)
{//createOpenCVWindow(); createCentralWindow(); createDockingWindow_One(); VideoHeader newVideo; //videoCap(); //createDockingWindow_Two();
}
-
Hi,
That's because you are creating an infinite loop that doesn't let Qt's event loop run.
This post describes an interesting way of using OpenCV capture with a Qt GUI.
Hope it helps
-
wrote on 18 Dec 2016, 23:18 last edited by
Thanks for the response! That link has lead me down the right path I believe. Using QThread to run the VideoCapture function portion and it appears to be working somewhat properly now.
-
Great !
Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)
1/4