From 662c58ca868336c9eba12ed04ad92980aa97939e Mon Sep 17 00:00:00 2001 From: Yannick Verdie Date: Sun, 15 Aug 2010 20:43:54 +0000 Subject: [PATCH] Qt bug fixed with cvWaitKey(0) --- modules/highgui/src/window_QT.cpp | 23 ++++++++++++++++++----- modules/highgui/src/window_QT.h | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 864f46ede8..2b02861e6a 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -1979,8 +1979,8 @@ ViewPort::ViewPort(CvWindow* arg, int arg2, int arg3) if ( mode_display == CV_MODE_OPENGL) { - //QGLWidget* wGL = new QGLWidget(QGLFormat(QGL::SampleBuffers)); - setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); + myGL = new QGLWidget(QGLFormat(QGL::SampleBuffers)); + setViewport(myGL); if (param_keepRatio == CV_WINDOW_KEEPRATIO) { //TODO: fix this bug: @@ -2027,6 +2027,14 @@ ViewPort::~ViewPort() if (image2Draw_ipl) cvReleaseImage(&image2Draw_ipl); + +#if defined( HAVE_QT_OPENGL ) + if (myGL) + delete myGL; +#endif; + + qDebug()<<"kill vieport"; + delete timerDisplay; } @@ -2198,13 +2206,16 @@ void ViewPort::updateImage(void* arr) //the ipl image in qt format (with shared memory) //image2Draw_qt = QImage((uchar*) image2Draw_ipl->imageData, image2Draw_ipl->width, image2Draw_ipl->height,QImage::Format_RGB888); - nbChannelOriginImage = tempImage->nChannels; + //nbChannelOriginImage = tempImage->nChannels; updateGeometry(); } - cvCvtColor(tempImage,image2Draw_ipl,CV_BGR2RGB); - //cvConvertImage(tempImage,image2Draw_ipl,CV_CVTIMG_SWAP_RB ); + nbChannelOriginImage = tempImage->nChannels; + + + //cvCvtColor(tempImage,image2Draw_ipl,CV_BGR2RGB);//will not work if tempImage is 1 channel !! + cvConvertImage(tempImage,image2Draw_ipl,CV_CVTIMG_SWAP_RB ); viewport()->update(); } @@ -2289,6 +2300,7 @@ void ViewPort::moveView(QPointF delta) { param_matrixWorld.translate(delta.x(),delta.y()); controlImagePosition(); + viewport()->update(); } //factor is -0.5 (zoom out) or 0.5 (zoom in) @@ -2331,6 +2343,7 @@ void ViewPort::scaleView(qreal factor,QPointF center) void ViewPort::wheelEvent(QWheelEvent *event) { scaleView( -event->delta() / 240.0,event->pos()); + viewport()->update(); } void ViewPort::mousePressEvent(QMouseEvent *event) diff --git a/modules/highgui/src/window_QT.h b/modules/highgui/src/window_QT.h index 32592e2082..a397e64a2d 100644 --- a/modules/highgui/src/window_QT.h +++ b/modules/highgui/src/window_QT.h @@ -438,7 +438,7 @@ private: void icvmouseProcessing(QPointF pt, int cv_event, int flags); #if defined( HAVE_QT_OPENGL ) - QPointer myGL; + QPointer myGL; double angle; double zmin; double zmax;