C++ Boost线程组返回空矩阵(openCV)
我试图使用boost库中的thread_组来操作openCV库中的矩阵对象(该程序是用C++编写的)。 但是,当我再次加入主线程后尝试保存矩阵时,矩阵不包含任何数据。 有人能举个例子说明如何使用boost thread_group操作矩阵吗?(我真的需要多线程,否则计算需要几天时间) 以下是我目前使用的代码:C++ Boost线程组返回空矩阵(openCV),c++,multithreading,opencv,boost,matrix,C++,Multithreading,Opencv,Boost,Matrix,我试图使用boost库中的thread_组来操作openCV库中的矩阵对象(该程序是用C++编写的)。 但是,当我再次加入主线程后尝试保存矩阵时,矩阵不包含任何数据。 有人能举个例子说明如何使用boost thread_group操作矩阵吗?(我真的需要多线程,否则计算需要几天时间) 以下是我目前使用的代码: Mat myMatrix; // Start threads boost::thread_group threadGroup; threadGroup.create_thread(boos
Mat myMatrix;
// Start threads
boost::thread_group threadGroup;
threadGroup.create_thread(boost::bind(&manipulateMatrixFunction,myMatrix));
threadGroup.join_all();
矩阵仅在主线程中声明。行数、列数和数据类型的初始化在“操纵器矩阵函数”中进行。(这可能是问题的一部分?通过引用传递
Mat
实例:
#include <boost/ref.hpp>
//...
threadGroup.create_thread(boost::bind(&manipulateMatrixFunction,boost::ref(myMatrix)));
//...
#包括
//...
创建_线程(boost::bind(&manipleMatrix函数,boost::ref(myMatrix));
//...
但请确保此实例比线程更有效。好的,我自己检查过:)。因此,在线程中操作矩阵之前,必须对其进行初始化。尽管如此,我还是希望初始化函数“manufactureMatrixFunction”中的矩阵。有什么建议吗?