Illegal call of non-static member function in C++

2019-09-16 14:49发布

问题:

I'm trying to use this function, but I cannot find any examples. So I tried every possible way that I can think of, and each time I get a different error :

cv::Mat salMap;
cv::saliency::StaticSaliencySpectralResidual::computeSaliency(img, salMap);

this causes in error :

'cv::saliency::Saliency::computeSaliency': illegal call of non-static member function

Then I tried to instantiate the class like this :

cv::saliency::StaticSaliencySpectralResidual myObj;
myObj.computeSaliency(grayImg, salMap); // also tried "->" instead of "."

and here is the error I got :

Error   LNK2001 unresolved external symbol "public: bool __cdecl cv::saliency::Saliency::computeSaliency(class cv::_InputArray const &,class cv::_OutputArray const &)" (?computeSaliency@Saliency@saliency@cv@@QEAA_NAEBV_InputArray@3@AEBV_OutputArray@3@@Z)

Error   LNK2001 unresolved external symbol "public: virtual __cdecl cv::saliency::Saliency::~Saliency(void)" (??1Saliency@saliency@cv@@UEAA@XZ)

So how can I use this class?

Thanks for any help !