in a file OrbCudaTracker.h I have a class OrbCudaTracker with a member function ProcessNewFrame, as follows:
class OrbCudaTracker
{
public:
OrbCudaTracker();
~OrbCudaTracker();
void ProcessNewFrame(const cv::cuda::GpuMat &frame, MatchingResult &resCam1, MatchingResult &resCam2, int buffInd);
};
from main.cpp, I would like to start a separate thread running ProcessNewFrame from an object of class OrbCudaTracker, as follows:
OrbCudaTracker tracker;
MatchingResult r1, r2;
int buffInd = 0;
cuda::GpuMat cudaCurrImage;
std::thread tProcess(&OrbCudaTracker::ProcessNewFrame, &tracker, cudaCurrImage, r1, r2, buffInd);
/*Another thread starting here*/
tProcess.join();
tAnother.join();
However, when I compile I get the following error message:
/usr/include/c++/4.8/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (OrbCudaTracker::*)(const cv::cuda::GpuMat&, MatchingResult&, MatchingResult&, int)>(OrbCudaTracker*, cv::cuda::GpuMat, MatchingResult, MatchingResult, int)>’ typedef typename result_of<_Callable(_Args...)>::type result_type; ^ /usr/include/c++/4.8/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (OrbCudaTracker::*)(const cv::cuda::GpuMat&, MatchingResult&, MatchingResult&, int)>(OrbCudaTracker*, cv::cuda::GpuMat, MatchingResult, MatchingResult, int)>’ _M_invoke(_Index_tuple<_Indices...>)
I am compiling on Ubuntu 14.04.1 LTS with gcc 4.8.4 on a Tegra TX1. In my cmake file I have enabled the -std=c++11 flag. I have followed the syntax explained here:
How to, in C++11, use std::async on a member function?
But I get the compilation error reported above. Any help would be very much appreciated. Thank you for your time.
Update: I have tried to replace the line:
std::thread tProcess(&OrbCudaTracker::ProcessNewFrame, &tracker, cudaCurrImage, r1, r2, buffInd);
with
std::thread tProcess(&OrbCudaTracker::ProcessNewFrame, std::ref(tracker), cudaCurrImage, r1, r2, buffInd);
as shown in the link suggested in the comments. Now the compilation error looks like:
/usr/include/c++/4.8/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (OrbCudaTracker::*)(const cv::cuda::GpuMat&, MatchingResult&, MatchingResult&, int)>(std::reference_wrapper<OrbCudaTracker>, cv::cuda::GpuMat, MatchingResult, MatchingResult, int)>’ typedef typename result_of<_Callable(_Args...)>::type result_type; ^ /usr/include/c++/4.8/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (OrbCudaTracker::*)(const cv::cuda::GpuMat&, MatchingResult&, MatchingResult&, int)>(std::reference_wrapper<OrbCudaTracker>, cv::cuda::GpuMat, MatchingResult, MatchingResult, int)>’ _M_invoke(_Index_tuple<_Indices...>)