0

Client recieve image (Image.FromStream) over network (Windows Forms C#). Server send image as byte array (bmp format). How to convert IplImage opencv to byte array (bmp format) C++? Without saving to a file (performance).

Artyom Smirnoff
  • 57
  • 2
  • 11

2 Answers2

1

Try to use opencv function imencode

Description

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

Example

vector<uchar> buf;
Mat matImage = iplImage;
imencode(".bmp", matImage, buf);
size = buf.size();
copy(buf.begin(), buf.end(), byteArray);
nikolna85
  • 26
  • 2
0

It depends if you just want to save the file or if you want to code a structure for it.

cvSaveImage("foo.bmp",img); // img is your IplImage

read bitmap file into structure describes how you can define a nice structure for your bmp file if you want to send it from the server (it's C but if you want, I guess you can adapt it)

Community
  • 1
  • 1
wrousseau
  • 311
  • 3
  • 12