QObject::killTimer: Timers cannot be stopped from another thread (when using waitKey function)

Hi, all!

I’m using 2 threads in my code (both started from main thread which sleeps and waits till the 2 threds will finish), one decodes frames, the other blits them to a window. In the thread that blits, I use the following code:

cv::Mat img_buffer(h, w, CV_8UC1, data);
cv::Mat original;
cv::cvtColor(img_buffer, original, cv::COLOR_YUV2RGB_YV12);
cv::imshow("Original", original);
cv::waitKey(25);

When I reach the end of frames, I call

cv::destroyWindow("Original");

When main exits, I got warnings at the end:

QObject::killTimer: Timers cannot be stopped from another thread
QObject::~QObject: Timers cannot be stopped from another thread

I ran both the opencv and QT libs under gdb and found out that the timer that was not terminated prior to exit from main was a QPixmapCache 30-second timer (qtbase/src/gui/image/qpixmapcache.cpp). I can tackle the issue by adding

QPixmapCache::clear();

in GuiReceiver::isLastWindow() (window_QT.cpp in opencv src) just to make sure that some cleanup was fogotten somewhere.

I wanted to ask if I’m using opencv in wrong manner for what I want to achieve (perhaps I forget something or the code snippet I use is not proper) or there is a bug (in opencv? qt?)?

I use opencv 4.6.0 and QT 6.4.2.

Thanks,
Alexei

opencv’s gui functions are expected to run all from the (single) main thread, so:

this is a bad idea.

i also doubt, that you get any efficiency boost from it.
keep it in a single thread, simply.