Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

that'll be somewhat more complicated, that you expected. you can't simply take the address of it, and send it over the wire, this is c++, not C. what i'd propose is:

server:

  • first send the number of images
  • imencode() each Mat to jpeg (don't ever send uncompressed megabyte pixel images over the wire !)
  • send the encoded bytes (one write() per image)

client:

  • read the number of images
  • for each image, have a loop that reads only small packets, like 4k bytes (network fragmentation !). once you recv less than that, you know, that the transmission of an image buffer ended
  • imdecode() the jpeg buffers back to cv::Mat
  • reassemble a vector<Mat>from that

that'll be somewhat more complicated, that you expected. you can't simply take the address of it, and send it over the wire, this is c++, not C. what i'd propose is:

server:

  • first send the number of images
  • imencode() each Mat to jpeg (don't ever send uncompressed megabyte pixel images over the wire !)
  • !).* send the encoded bytes (one write() per image)image). you'll get a vector<uchar> vec, and send(sock, vec.data(), vec.size())

client:

  • read the number of images
  • for each image, have a loop that reads only small packets, like 4k bytes (network fragmentation !). once you recv less than that, you know, that the transmission of an image buffer ended
  • imdecode() the jpeg buffers back to cv::Mat
  • reassemble a vector<Mat>from that

that'll be somewhat more complicated, that you expected. you can't simply take the address of it, and send it over the wire, this is c++, not C. what i'd propose is:

server:

  • first send the number of images
  • imencode() each Mat to jpeg (don't ever send uncompressed megabyte pixel images over the wire !).* !).
  • send the encoded bytes (one write() per image). you'll get a vector<uchar> vec, and send(sock, vec.data(), vec.size())

client:

  • read the number of images
  • for each image, have a loop that reads only small packets, like 4k bytes (network fragmentation !). once you recv less than that, you know, that the transmission of an image buffer ended
  • imdecode() the jpeg buffers back to cv::Mat
  • reassemble a vector<Mat>from that

that'll be somewhat more complicated, that than you expected. you can't simply take the address of it, and send it over the wire, this is c++, not C. what i'd propose is:

server:

  • first send the number of images
  • imencode() each Mat to jpeg (don't ever send uncompressed megabyte pixel images over the wire !).
  • send the encoded bytes (one write() per image). you'll get a vector<uchar> vec, and send(sock, vec.data(), vec.size())

client:

  • read the number of images
  • for each image, have a loop that reads only small packets, like 4k bytes (network fragmentation !). once you recv less than that, you know, that the transmission of an image buffer ended
  • imdecode() the jpeg buffers back to cv::Mat
  • reassemble a vector<Mat>from that