-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSocketMatTransmissionClient.h
60 lines (50 loc) · 1.11 KB
/
SocketMatTransmissionClient.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __SOCKETMATTRANSMISSIONCLIENT_H__
#define __SOCKETMATTRANSMISSIONCLIENT_H__
#include "opencv2/opencv.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
using namespace cv;
//待传输图像默认大小为 640*480,可修改
#define IMG_WIDTH 640 // 需传输图像的宽
#define IMG_HEIGHT 480 // 需传输图像的高
#define PACKAGE_NUM 1
//默认格式为CV_8UC3
#define BUFFER_SIZE IMG_WIDTH*IMG_HEIGHT*3/PACKAGE_NUM
struct sentBuf
{
char head[2];
char buf[BUFFER_SIZE];
//int flag;
};
struct recvBuf
{
char head[2];
char buf[BUFFER_SIZE];
//int flag;
};
class SocketMatTransmissionClient
{
public:
SocketMatTransmissionClient(void);
~SocketMatTransmissionClient(void);
private:
int sockClient;
struct sentBuf data;
struct recvBuf data_r;
int needRecv;
int count;
public:
int socketConnect(const char* IP, int PORT);
int transmit(cv::Mat image);
int transmit_stop(void);
int receive(cv::Mat& image);
void socketDisconnect(void);
};
#endif