I'm using Qt as my C++ IDE platform over Ubuntu 10.10 with OpenCV 2.2.
I'll just write pieces of code 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 seems something like this:
VIDIOC_QUERYMENU: Invalid argument
And everything seems to be fine (the camera works).
I had to add usage of the Qt and added 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 the 3 warning lines but now, the "frame" window is grey, and nothing is shown.
This is my first time using Qt, so I don't really know how it works. I can only guess that QApplication is getting control over the window management, that causes the imshow
command to not be able to open a new window.