[英]How to convert IplImage opencv to byte array (bmp format) C++?
Client recieve image ( Image.FromStream ) over network (Windows Forms C#). 客户端通过网络(Windows Forms C#)接收图像( Image.FromStream )。 Server send image as byte array (bmp format).
服务器将图像作为字节数组(bmp格式)发送。 How to convert IplImage opencv to byte array (bmp format) C++?
如何将IplImage opencv转换为字节数组(bmp格式)C ++? Without saving to a file (performance).
不保存到文件(性能)。
Try to use opencv function imencode 尝试使用opencv函数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);
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) 将位图文件读入结构描述了如果您要从服务器发送bmp文件,则如何定义一个不错的结构(它是C,但是如果您愿意,我想您可以对其进行调整)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.