Search code examples
opencvoverloadingoperator-keywordmser

How to use the () operator of mser of opencv


I am using opencv MSER class, cannot compile a use of () operator. I am not a c++ expert, so post question here, hope somebody can help.

MSER class is defined including a () operator:

class CV_EXPORTS_W MSER : public CvMSERParams
{
public:
   ...
    void operator()( const Mat& image,
    CV_OUT vector<vector<Point> >& msers, const Mat& mask ) const;
};

The code snippet to use MSER class:

Mat yuv;
vector<vector<Point> > contours;
cv::MSER mser;
mser(yuv, contours, cv::Mat());

at the mser() line, xcode give me this error:

No matching function for call to object of type 'cv::MSER'

Solution

  • The problem is with this line

    vector<vector<Point> > contours;
    

    Change it to

    vector<vector<cv::Point> > contours;
    

    The problem is that there is already a Point defined in the Cocoa frameworks, so the compiler is looking for a version of the operator that doesn't exist.