cv::namedWindow是非线程安全的

cv::namedWindow用于创建一个窗口,一般和imshow一起使用.但cv::namedWindow是非线程安全的,当多个线程同时显示图像时,cv::namedWindow可能因为资源竞争而崩溃:

cannot register existing type 'gdkdevice'
cannot register existing type 'gtkthemeengin
std::mutext cv_mtx;

cv_mtx.lock();
cv::namedWindow("Win", cv::WINDOW_KEEPRATIO | cv::WINDOW_NORMAL);
cv_mtx.unlock();

cv::imshow("Win", image);

posted @ 2020-11-30 10:37  Cristiano-Duan  阅读(452)  评论(0编辑  收藏  举报