In short, I get the following error:
QObject::connect: Cannot queue arguments of type 'cv::Mat' (Make sure 'cv::Mat' is registered using qRegisterMetaType().)
What I'm trying to do is send a signal containing two cv :: Mat images from QThread to the main thread so that I can display the output. There is no compile-time error, but when I run the program, it gets stuck at the breakpoint in qglobal.h ( inline void qt_noop() {} ).
I tried adding Q_DECLARE_METATYPE(cv::Mat) to the code, but to no avail. I'm pretty suck what to do now.
the code
In the QThread class:
signals: void sndFlow(cv::Mat &leftEye, cv::Mat &rightEye); void eyesDriver::run() { forever { flow->draw(leftEye, rightEye); sndFlow(leftEye, rightEye); } }
Capture in the QObject class:
public slots: void recFlow(cv::Mat &leftEye, cv::Mat &rightEye); void myClass::recFlow(cv::Mat &leftEye, cv::Mat &rightEye) { cv::imshow("left", leftEye); cv::imshow("rigth", rightEye); cv::waitKey(40); }
Mostly:
Q_DECLARE_METATYPE(cv::Mat) int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); qRegisterMetaType< cv::Mat >("cv::Mat");
Changing the signal slot variables to QSharedPointer< cv::Mat > does not work either. Gives the same error:
QObject::connect: Cannot queue arguments of type 'QSharedPointer<cv::Mat>' (Make sure 'QSharedPointer<cv::Mat>' is registered using qRegisterMetaType().)
Work
Good, it seems to work. I move qRegisterMetaType< cv::Mat >("cv::Mat"); right before calling QObject::connect . However, I still need βF5β to go through the breakpoint in qglobal.h, after which it works.
Maybe I'm wrong, but it seems that the qRegisterMetaType not trivial.
qt opencv signals-slots qthread
Raf berkvens
source share