-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (29 loc) · 829 Bytes
/
Copy pathmain.cpp
File metadata and controls
32 lines (29 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include "msgqueue.h"
#include "JPEGDecoder.h"
#include "ReceiveSocket.h"
#include <opencv2/opencv.hpp>
int main() {
CJPEGDecoder decoder;
CReceiveSocket s;
s.Listen();
puts("$$$$$");
s.AcceptFromClient();
puts("$$$$$");
char* pData; //分配接收客户端返回内容的内存
pData = new char[MAX_IMAGE_SIZE];
s.ReceiveFromClient(pData, MAX_IMAGE_SIZE);
if (!decoder.Decode((uint8_t*)s.pData , s.imageSize))
{
int width;
int height;
decoder.GetSize(width, height);
std::cout << width << " && " << height << std::endl;
cv::Mat image(cv::Size(s.width, s.height), CV_8UC1);
decoder.GetData(image.data);
cv::imshow("receive image", image);
cv::waitKey(0);
}
delete []pData;
return 0;
}