Problem to send Mat images over TCP/IP
Hello community,
Actually, I capture images from a Gige camera on jetson TX2 (which runs with ubuntu). I process the image, and I stock it in Mat matrice. The image resolution is 3840*5120.
Then, I need to transfert that image toward windows computer. Windows is the server, and linux the client.
To send all kinds of type, I have to use a structure. So, from the client, I have (I don´t respect thje camera´s resolution here) :
client side
struct Image
{
cv::Mat img = cv::Mat::zeros(768, 1024, CV_8UC3);
};
Image imgTest = frame ;
....
error=send(sock, &imgTest, sizeof(imgTest), 0) ;*
server side
struct Image
{
cv::Mat img = cv::Mat::zeros(768, 1024, CV_8UC3);
};
Image imgTest ;*
...
if (recv(csock, (char *)&imgTest, sizeof(imgTest), 0) != SOCKET_ERROR){
std::cout << "Receive" << std::endl ;
}
The code crash. Why the argument of the function in windows and linux are differents ?
On linux, we have :
int send(int socket, void* buffer, size_t len, int flags);
int recv(int socket, void* buffer, size_t len, int flags);
On windows, we have :
int send(int socket, char* buffer, size_t len, int flags);
int recv(int socket, char* buffer, size_t len, int flags);
I cast the struct in "char *", and I know that is the problem. Someone has an idea to solve it ? I know there already is a page about that topic, but I am not interested by the solution. You suggest to send an array of char. In my case, the size of the array is 19,660,800 (I work with grayscale), means almost 20 Go only for the buffer, and my RAM is not big enought .
Thank you, NL37
3480*5120*3 = 53452800
(at least in my maths) so 53mb for color or ~17mb for grayscaleand no, you cannot send a
Mat
object over the wire (it's non POD)try with
Mat.data
instead, or better, compress it usingimencode()