QT uses slots to pass OPENCV objects in the mat and to integrate open source code with multithreading.

Source: Internet
Author: User
Tags emit

About the slot delivery Mat object

Previously, the Qtimer timer was used, and the mat member implementation of the Read dialog object after the timeout was set to display the image in the UI, which added complexity to subsequent integration of other process-oriented code.

So consider using slots

Even after processing the image with multithreading, send signal to the Dialog object, dialog connect them on the line.

Child threads. cpp

...

for (;;) {

...

Emit imagechanged (LABELIMG);

...

}

Emit finished ();

...

Dialog.h

...

Private Slots:
void UpdateImage (const cv::mat &img);

...

Dialog.cpp

...

qregistermetatype< cv::mat > ("Cv::mat");
Connect (worker, SIGNAL (imagechanged (const Cv::mat &)), this, SLOT (updateimage (const Cv::mat &));

...

Child threads. h

...

Signals:
void imagechanged (const cv::mat &img);

...

//////////////

Parent class Worker

Public Slots:
virtual void DoWork ();

Child threads

Class Ctworker:public Worker

{
Public
Ctworker ();
Public Slots:
void DoWork (); The overlay is OK.
};

#endif//Ctworker_h

QT uses slots to pass OPENCV objects in the mat and to integrate open source code with multithreading.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.