c++opencviplimage

Convert Mat to IplImage* in OpenCV and C/C++


in my application I have a Mat file which i'd like to show in a window with cvShowImage which is defined as:

void cvShowImage( const char* name, const CvArr* image )

Now, the problem is that if i pass directly the Mat image, it gives me an error conversion:

cannot convert 'cv::Mat' to 'const CvArr*' for argument '2' to 'void cvShowImage(const char*, const CvArr*)'

I tryed to search in this forum for someone with the same problem and i found this opencv documentation: http://opencv.willowgarage.com/documentation/cpp/c++_cheatsheet.html

But i didn't understand how to use it.

Can someone give me an example of how to convert Mat image to IplImage, please?

This is my code:

Mat file;
Mat hogResultFrame = hogStep(temp2);
file = hogResultFrame;

  cvShowImage(window_title, (const CvArr*)(file));

but it gives me an error coversion.

I hope you can help me,

thanks a lot!


Solution

  • Why do you try to use the C interface with C++ datatypes? Use the C++ interface.

    cv::namedWindow(window_title, 1);
    cv::imshow(window_title, file);