Boost thread_group 返回空矩阵 (openCV)
Boost thread_group returns empty Matrix (openCV)
我正在尝试使用提升库中的thread_group来操作 openCV 库中的矩阵对象(该程序是用 C++ 编写的)。但是,当我再次加入主线程后尝试保存矩阵时,矩阵不包含任何数据。任何人都可以提供如何使用升压thread_group操作矩阵的示例吗?(我真的需要多线程,否则计算需要几天时间)
这是我到目前为止使用的代码:
Mat myMatrix;
// Start threads
boost::thread_group threadGroup;
threadGroup.create_thread(boost::bind(&manipulateMatrixFunction,myMatrix));
threadGroup.join_all();
矩阵仅在主线程中声明。行数、列数和数据类型的初始化发生在"manipulateMatrixFunction"中。(也许这是问题的一部分?
通过引用传递Mat
实例:
#include <boost/ref.hpp>
//...
threadGroup.create_thread(boost::bind(&manipulateMatrixFunction,boost::ref(myMatrix)));
//...
但请确保此实例的寿命超过线程。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将OpenCV C++重写为EmguCV C#-如何使用指针
- OpenCV C++.快速计算混淆矩阵
- 在C++代码中包含opencv时,使用ctypes创建.so文件
- 在std::thread中,joinable()然后join()线程安全吗
- 哪些库可以通过Opencv调整曝光率
- 安装opencv失败-粘贴CMakeError.log的内容
- C++中的openCV Mat访问冲突
- OpenCV Android C++ imwrite not found
- <Windows>为什么 std::thread::native_handle 返回类型为"long long unsigned int"的值,而不是 void*(又名 HANDLE)?
- 分离一个静态常量 std::thread?
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 将 OpenCV 与 CMAKE 中的项目一起构建为第三方库的正确方法
- CV_OCL_RUN宏如何在OpenCV(版本3.4.5)的goodFeaturesToTrack实现中工作?
- OpenCV 4.1.2 - 从网络摄像头获取帧并将其拆分
- OpenCV OpenCL Thread Saftey - Deadlock (将 cv::Mat 更改为 UMat)