C++ c++;套接字接收图像并显示,但不保存
我想从客户端接收图像 当我们将图像保存到JPG文件时,可以在服务器端显示它 像这样C++ c++;套接字接收图像并显示,但不保存,c++,sockets,opencv,C++,Sockets,Opencv,我想从客户端接收图像 当我们将图像保存到JPG文件时,可以在服务器端显示它 像这样 char *buff = (char*)malloc(sizeof(char) * (240*360)); FILE *output; output = fopen("test.jpg", "wb"); unsigned int readBytes = 0; while(true) { int ret
char *buff = (char*)malloc(sizeof(char) * (240*360));
FILE *output;
output = fopen("test.jpg", "wb");
unsigned int readBytes = 0;
while(true)
{
int ret = recv(sClient, buff+readBytes, (240*360)-readBytes, 0);
if (ret <= 0)
{
break;
}
readBytes += ret;
}
fwrite(buff, sizeof(char), readBytes, output);
fclose( output );
Mat img_2 = imread( "test.jpg");
char*buff=(char*)malloc(sizeof(char)*(240*360));
文件*输出;
输出=fopen(“test.jpg”、“wb”);
unsigned int readBytes=0;
while(true)
{
int-ret=recv(sClient,buff+readBytes,(240*360)-readBytes,0);
如果(ret“但是有没有办法通过接收字符*直接获取接收图像的Mat?”
是的,有。您可以使用