Richard Knop
Richard Knop

Reputation: 83697

How to use cv::imencode on IplImage?

I have an image saved in a variable fo type IplImage like this:

IplImage* fIplImageHeader;
fIplImageHeader = cvCreateImageHeader(cvSize(width, height), 8, 3);
fIplImageHeader->imageData = (char*) memblock;

How can I use the cv::imencode function on that image?

cv:imencode looks like this:

bool imencode(const string& ext, const Mat& img, vector<uchar>& buf, const vector<int>& params=vector<int>())

So obviously I need to convert IplImage to const Mat somehow but I cannot find how to do that in the documentation.

What should I do?

This does not work of course:

cv::imencode("JPG", fIplImageHeader, fIplImageHeader);

Upvotes: 0

Views: 6736

Answers (1)

Richard Knop
Richard Knop

Reputation: 83697

See my other question:

OpenCV - could not find encoder for the specified extension

Where I have solved the problem.

Upvotes: 1

Related Questions