Zuoshu Lu
Zuoshu Lu

Reputation: 67

Convert Emgu CV Image to jpeg 2000 then store to an byte array

I can save a jpeg 2000 image file by following

Image<Bgr, byte> img; img.Save("photo.jp2");

How can I convert Emgu CV Image to jpeg 2000 then store to an byte array

Upvotes: 0

Views: 2374

Answers (1)

kmp
kmp

Reputation: 10865

The Image class in emguv has a Bitmap property (see: Image(TColor, TDepth).Bitmap in the emgucv documentation) and so if you want just a JPEG encoded byte array for the image you can do this:

Image<Bgr, byte> img;

//...

byte[] bytes;
using(var ms = new MemoryStream())
{
    img.Bitmap.Save(ms, ImageFormat.Jpeg);
    bytes = ms.ToArray();
}

Upvotes: 1

Related Questions