ubuntu error: no matching function for call to ‘cv::Mat::Mat(IplImage*&)’

问题

Tried to compile some code that uses OpenCV and got this error:

1

foo.cpp:268:27: error: no matching function for call to ‘cv::Mat::Mat(IplImage*&)’

The code at that error line tries to construct a cv::Mat object from IplImage:

1

2

3

4

5

6

void boohoo(IplImage* i)

{

    // ...

    abracadabra(cv::Mat(i));

    // ...

}

解决办法

It turns out this code worked in older versions of OpenCV. But with recent versions of OpenCV, this cv::Mat constructor is no longer present.

Instead, the conversion has to be performed using a cv::cvarrToMat function:

1

2

3

4

5

6

void boohoo(IplImage* i)

{

    // ...

    abracadabra(cv::cvarrToMat(i));

    // ...

}

Tried with: OpenCV 2.4.9 and Ubuntu 12.04 LTS

你可能感兴趣的:(ubuntu error: no matching function for call to ‘cv::Mat::Mat(IplImage*&)’)