Hey guys, I am using Qt as a C ++ IDE platform on top of Ubuntu 10.10 with OpenCV 2.2. I will just write the code snippets and show where the problem is:
#include "opencv2/highgui/highgui.hpp" using namespace cv; int main(int argc, char *argv[]) { VideoCapture cap = VideoCapture(0); Mat frame; do { cap >> frame; imshow("frame",frame); } while (waitKey(10) != 27); return 0; }
I get 3 warning printouts that look something like this:
VIDIOC_QUERYMENU: Invalid argument
And everything seems beautiful (the camera is working).
I had to add using Qt and add 3 lines of code, and it looks like this:
#include <QApplication> #include "opencv2/highgui/highgui.hpp" using namespace cv; int main(int argc, char *argv[]) { QApplication app(argc,argv); VideoCapture cap = VideoCapture(0); Mat frame; do { cap >> frame; imshow("frame",frame); } while (waitKey(10) != 27); return app.exec(); }
I still get 3 warning lines, but now the "frame" window is gray and nothing is displayed.
This is my first time using Qt, so I really don't know how this works. I can only guess that QApplication is gaining control over window management, which means that the imshow command imshow not open a new window.
I would be grateful for your help, Thnx!
source share