在OrbCudaTracker.h文件中我有一个带有成员函数ProcessNewFrame的OrbCudaTracker类,如下所示:
class OrbCudaTracker
{
public:
OrbCudaTracker();
~OrbCudaTracker();
void ProcessNewFrame(const cv::cuda::GpuMat &frame, MatchingResult &resCam1, MatchingResult &resCam2, int buffInd);
};
从main.cpp ,我想从类OrbCudaTracker的对象启动一个运行ProcessNewFrame的独立线程,如下所示:
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();
但是,当我编译时,我收到以下错误消息:
/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...>)
我正在使用Tegra TX1上的gcc 4.8.4编译Ubuntu 14.04.1 LTS。 在我的cmake文件中,我启用了-std = c ++ 11标志。 我遵循了这里解释的语法:
How to, in C++11, use std::async on a member function?
但我收到上面报告的编译错误。任何帮助将非常感谢。谢谢你的时间。
更新:我试图替换该行:
std::thread tProcess(&OrbCudaTracker::ProcessNewFrame, &tracker, cudaCurrImage, r1, r2, buffInd);
与
std::thread tProcess(&OrbCudaTracker::ProcessNewFrame, std::ref(tracker), cudaCurrImage, r1, r2, buffInd);
如评论中建议的链接所示。现在编译错误如下:
/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...>)