0

I have a use case to send an OpenCV Mat object to multiple receivers in a multicast network. I use C++ boost library to send and receive the multicast network data.

My understanding

Mat object is serialized to a boost buffer and sent to network receivers. Receivers receive and deserialize the buffer to construct a Mat object.

Implementation I tried

My Mat object to be sent is image.

const char * px = reinterpret_cast<const char*>(image.data);
socket_.async_send_to(
            boost::asio::buffer(px, sizeof(px)), endpoint_,
            [this](boost::system::error_code ec, std::size_t /*length*/) {
                if (!ec && message_count_ < max_message_count)
                    do_timeout();
            });

Question 1

How to check if the complete data has reached the receiver?

Question 2

How to reconstruct the Mat object at receiver?

Question 3

Is there a better way to construct an image buffer which transfer OpenCV Mat objects in a multicast network? (I appreciate the use of boost library since it is used at multiple places)

Sleeba Paul
  • 613
  • 1
  • 6
  • 14
  • Which type of image data are you sending? – AchimGuetlein Mar 07 '19 at 09:17
  • I'm grabbing my webcam feed to a `Mat` object using OpenCV. – Sleeba Paul Mar 07 '19 at 09:25
  • 1
    For the reconstruction you will need more information than only data. You will need to know width and height of the image also the original type from OpenCv e.g CV_8UC1 or other to properly reinterpret the data in there. I am not sure but you might also need stride value – wdudzik Mar 07 '19 at 10:04
  • 1
    Use google protobuf: https://stackoverflow.com/questions/4810026/sending-protobuf-messages-with-boostasio – Nuzhny Mar 07 '19 at 11:49

0 Answers0