1
我想从boost库中使用thread_group来从openCV库(程序是用C++编写的)操作矩阵对象。 但是,当我在再次加入主线程后尝试保存矩阵时,矩阵不包含任何数据。 任何人都可以提供一个例子如何使用boost thread_group来操纵矩阵? (我真的需要多线程,因为计算需要数天以其他方式)Boost thread_group返回空矩阵(openCV)
这里是我使用至今代码:
Mat myMatrix;
// Start threads
boost::thread_group threadGroup;
threadGroup.create_thread(boost::bind(&manipulateMatrixFunction,myMatrix));
threadGroup.join_all();
矩阵仅在主线程声明。行数,列数和数据类型的初始化发生在“manipulateMatrixFunction”中。 (也许这就是问题的一部分?)
好的,我自己检查了一下:)。所以矩阵必须在线程中操作之前进行初始化。仍然我宁愿在函数“manipulateMatrixFunction”中初始化矩阵。有什么建议么? – mcExchange