Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way could be,

  • Load images to Mat which give you continuous BGR pixel array,
  • Append all Mat together to form a big Mat, use Mat::push_back().
  • Encode the final Mat using imencode() and send it.
  • At the receiver side use imdecode() to get the pixels in BGR order.
  • Use ROI to split to images(as you already know image height).

Here is an example

Mat img1=imread("1.png",CV_LOAD_IMAGE_COLOR);
Mat img2=imread("2.png",CV_LOAD_IMAGE_COLOR);
Mat combined=img1.clone();
combined.push_back(img2);

vector<uchar> buf1,buf2,buf3;
vector<int> param = vector<int>(2);
param[0]=CV_IMWRITE_JPEG_QUALITY;
param[1]=100;//default(95) 0-100

imencode(".jpg",img1,buf1 ,param);
imencode(".jpg",img2,buf2 ,param);
imencode(".jpg",combined,buf3 ,param);

Mat decoded = imdecode(Mat(buf),CV_LOAD_IMAGE_COLOR);