frame = cvQueryFrame(camera);
while(key!='q'){
cvNamedWindow( "main",CV_WINDOW_AUTOSIZE);
cvShowImage("main", frame);
if(frame!=NULL){
drawSquares( frame, findSquares4( frame, storage ) );
/* wait for key. Also the function cvWaitKey takes care of event processing */
key = cvWaitKey(33);
IplImage *img = cvCloneImage(frame);
if (img->origin){
cvFlip(img);
img->origin= 0;
}
QImage* qimg = IplImageToQImage(img)
// qimg = IplImage2QImage (img);
QLabel label;
ui->label->setPixmap(QPixmap::fromImage(qimg));
cvReleaseImage(&img);
I like to play video with Qt Creator. I use the code above, but it’s not okay. I get the following error:
IplImageToQImage was not declared in this scope
Does anyone know how I can play video with OpenCV and Qt Creator in the same window?
Well, it makes sense since
IplImage2QImage()is not a part of Qt nor OpenCV.You probably saw this function being used somewhere on the Internet and copied/pasted into your code.
With a simple search on Google I found the implementation of this function:
Hopefully you’ll know what to do with it.
I wrote this minimal example to show how to successfully use
IplImage2QImage(). It usescvLoadImage()to load a file named test.jpg from the disk and then displays it on a QLabel. It’s simple, and it works!On my Linux box, I compiled it with: