Question

I'm trying to use thread_group from the boost libraries to manipulate matrix objects from the openCV libraries (the program is written in C++). However when I try to save the matrices after joining the main thread again, the matrix doesn't contain any data. Can anyone provide an example how to manipulate matrices using boost thread_group ? (I really need multithreading, since the computation takes days otherwise)

Here is the code I'm using so far:

Mat myMatrix;
// Start threads
boost::thread_group threadGroup;
threadGroup.create_thread(boost::bind(&manipulateMatrixFunction,myMatrix));
threadGroup.join_all();

The matrix is only declared in the main thread. The initialisation with number of rows, cols and datatype takes place inside "manipulateMatrixFunction". (Maybe that is part of the problem?)

No correct solution

OTHER TIPS

Pass the Mat instance by reference:

#include <boost/ref.hpp>

//...
threadGroup.create_thread(boost::bind(&manipulateMatrixFunction,boost::ref(myMatrix)));
//...

But make sure that this instance outlives the thread.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top