Hi all,
I try to get the output of my webcam with opencv and display it through qt. Therefore I convert the IplImage into a QImage and call the function setPixmap() to draw the image onto a QLabel. Afterwards I repaint the QLabel to update it. Generally the output works fine but the program isn't responsive to any command. I can't close it by push esc or clicking on the "X" to close the window. My last option is to break the program by "ctrl-alt-del".

Does anybody has a hint or know where the problem lie?
I would be very excited for any help.
Thanks in advance and kind regards,
Saul

Thats my whole code:
Qt Code:
  1. // main.cpp
  2.  
  3. #include "webcam.h"
  4. #include <QtGui/QApplication>
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. QApplication a(argc, argv);
  9. Webcam w;
  10. w.show();
  11. return a.exec();
  12. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. // webcam.h
  2.  
  3. #ifndef WEBCAM_H
  4. #define WEBCAM_H
  5.  
  6. #include <QtGui/QMainWindow>
  7. #include "ui_webcam.h"
  8. #include "cv.h"
  9. #include "highgui.h"
  10.  
  11. class Webcam : public QMainWindow
  12. {
  13. Q_OBJECT
  14.  
  15. public:
  16. Webcam(QWidget *parent = 0, Qt::WFlags flags = 0);
  17. ~Webcam();
  18.  
  19. private:
  20. Ui::WebcamClass ui;
  21.  
  22. public slots:
  23. void showWebcam();
  24. };
  25.  
  26. #endif // WEBCAM_H
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. // webcam.cpp
  2.  
  3. #include "webcam.h"
  4.  
  5. Webcam::Webcam(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags)
  6. {
  7. ui.setupUi(this);
  8.  
  9. connect(ui.actionStart, SIGNAL(triggered()), this, SLOT(showWebcam()));
  10. }
  11.  
  12. Webcam::~Webcam() { }
  13.  
  14. void Webcam::showWebcam()
  15. {
  16. IplImage *image;
  17. CvCapture *capture;
  18. capture = cvCaptureFromCAM(0);
  19.  
  20. int esc = 0;
  21. while(true)
  22. {
  23. image = cvQueryFrame(capture);
  24.  
  25. cvCvtColor(image, image,CV_BGR2RGB);
  26. QImage qimg((const uchar *)image->imageData, image->width, image->height, QImage::Format_RGB888);
  27. ui.label->setPixmap(QPixmap::fromImage(qimg));
  28. ui.label->repaint();
  29.  
  30. esc = cvWaitKey(10);
  31. if (esc == 27) break;
  32. }
  33. cvReleaseCapture(&capture);
  34. }
To copy to clipboard, switch view to plain text mode