B
B
Bizman2015-06-11 21:48:07
C++ / C#
Bizman, 2015-06-11 21:48:07

How to send Iplimage and collect it on the receiving side using the UDP protocol?

There are two applications (server and client). Server sends imageData via udp socket. The client, in turn, accepts imageData inserts into Iplimage and displays.
Part of the server code.
IplImage *small is already filled with data.

char *buff;
buff=small->imageData;
int result = sendto(SendSocket,
                     buff, strlen(buff), 0, (SOCKADDR *) & RecvAddr, sizeof (RecvAddr));

Part of the client code.
int UDPMAX = 65507;
cvNamedWindow("Client", CV_WINDOW_AUTOSIZE); 
char *buff = (char*)malloc(UDPMAX);
int result = recvfrom(RecvSocket,
                       buff, strlen(buff), 0, (SOCKADDR *) & SenderAddr, &SenderAddrSize);
IplImage *small = cvCreateImage(cvSize(683,384), IPL_DEPTH_8U, 3);
buff[result]='\0';//обрезаю buff
small->imageData=buff;
cvShowImage("Client", small );

The data arrives at the client (the checksums are the same), but when cvShowImage is called, an error occurs. While debugging, I looked at the buff of the client and the buff of the server using TextVisualizer and noticed that they are different in some places (let's say "ЁўўўRRRRCC""" are replaced by "ЁўўўRRCCCCiii¶¶¶").

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question