OpenCV related C++ problem

Apr 7, 2012 at 4:07pm
Hey guys, so I am trying to use a particular class in OpenCV but I have never seen an operator like this so I am having trouble figuring out how to use it.

The constructor and main function for the class is shown as followed:

StarDetector::StarDetector(int maxSize, int responseThreshold, int lineThresholdProjected, int lineThresholdBinarized, int suppressNonmaxSize)

void StarDetector::operator()(const Mat& image, vector<KeyPoint>& keypoints) const


Now, I will show the code I used to try and use the StarDetector::operator() function that is shown above.


//Find Star Features from input Image
const cv::Mat Img = img;
vector<KeyPoint> keypoints;keypoints.reserve(100);
cv::StarDetector::StarDetector(32,30,40,80,20);
cv::StarDetector::operator()(Img,keypoints);


It gives me an error saying "a nonstatic member reference must be relative to a specific object"

I don't really know what to do given what it says, so can anyone help me out?

Thanks a lot!
Last edited on Apr 7, 2012 at 4:09pm
Apr 7, 2012 at 4:12pm
You need to initialize a StarDetector object first.

So something like
1
2
cv::StarDetector myStarDetector(32,30,40,80,20);
myStarDetector(Img, keypoints); // This is how you call operator() 
Last edited on Apr 7, 2012 at 4:12pm
Apr 7, 2012 at 4:15pm
Thanks a lot! Nailed it!
Apr 7, 2012 at 5:41pm
So I have actually had one error that I think should be a quick fix. Here is my tweaked code based on the first response to help my understanding on how to use an operator.

1
2
3
4
5
const cv::Mat Img = img; 
//Find Star Features from input Image
std::vector<KeyPoint> keypoints;
cv::StarDetector myDetector(32,30,40,80,20);
myDetector(Img,keypoints);


I get these errors when I do this and I don't know how to get this resolved.
1>TestingCV.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::StarDetector::operator()(class cv::Mat const &,class std::vector<class cv::KeyPoint,class std::allocator<class cv::KeyPoint> > &)const " (??RStarDetector@cv@@QBEXABVMat@1@AAV?$vector@VKeyPoint@cv@@V?$allocator@VKeyPoint@cv@@@std@@@std@@@Z) referenced in function _wmain
1>TestingCV.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::StarDetector::StarDetector(int,int,int,int,int)" (??0StarDetector@cv@@QAE@HHHHH@Z) referenced in function _wmain


Thanks for your help!
Apr 7, 2012 at 5:48pm
Did you link with the correct libraries?
Apr 7, 2012 at 5:57pm
I linked the project to the only folder that houses the libraries, I did also just double check this to make sure. Code I have written has worked up until I started using this and a couple other detector classes as I just a few minutes ago figured out.

Apr 7, 2012 at 6:16pm
Hmm, but did you link to the actual library files, instead of just pointing to the folder where those files are?
Apr 7, 2012 at 6:29pm
Hmm, I am looking and I may not have linked to all the library files and just the main ones, which would make sense of why it may not work. Let me try changing it and we'll see what happens.

Thanks!
Apr 7, 2012 at 9:19pm
Alright so I just added some of the libraries I needed for these classes and I got it to work. Thanks for helping me figure things out!
Topic archived. No new replies allowed.