0

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 !

jeff
  • 13,055
  • 29
  • 78
  • 136
  • 2
    You need to link the according library, your second attempt is correct otherwise. – Ulrich Eckhardt Oct 06 '15 at 20:31
  • @UlrichEckhardt thanks, but I already included `#include ` so the namespace is referenced correctly I guess. Visual Studio autocompletes all the class and fnnction names. – jeff Oct 06 '15 at 20:41
  • 2
    possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Daniel Jour Oct 06 '15 at 21:16
  • @halilpazarlama linking is not directly related to code but to your project setup. You have to setup your project accordingly. Crudly spoken, your compiler (linker to be more precise) is lacking the implementation for the given symbols. Similiar on how you have to setup include paths for header files, you must point your linker to where he can find the (precompiled) implementations. You should read up this question http://stackoverflow.com/questions/6264249/how-does-the-compilation-linking-process-work to get a better grasp on the topic. – Sebastian Hoffmann Oct 06 '15 at 21:45
  • Have you recompiled opencv with contrib modules? – Miki Oct 06 '15 at 21:54
  • [opencv_contrib readme](https://github.com/Itseez/opencv_contrib/blob/master/README.md) – maddouri Oct 06 '15 at 23:33
  • Sorry for the late reply. Yes I have linked OpenCV from the project properties, other OpenCV functions are working correctly. But I have manually copy-pasted 3 .hpp files (from [here](https://github.com/Itseez/opencv_contrib/tree/master/modules/saliency/include/opencv2)) related to saliency. So probably that was my fault. But OpenCV did not have them as default. So I wonder what was the correct way for this.. – jeff Oct 07 '15 at 00:30

0 Answers0