libvisiontransfer  5.1.0
imagetransfer.h
1 /*******************************************************************************
2  * Copyright (c) 2017 Nerian Vision Technologies
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *******************************************************************************/
14 
15 #ifndef VISIONTRANSFER_IMAGETRANSFER_H
16 #define VISIONTRANSFER_IMAGETRANSFER_H
17 
18 #include <string>
19 #include "visiontransfer/common.h"
20 #include "visiontransfer/imageprotocol.h"
21 #include "visiontransfer/imagepair.h"
22 
30 class VT_EXPORT ImageTransfer {
31 public:
36  UDP,
37 
40 
43  };
44 
49 
52 
56 
59 
61  WOULD_BLOCK
62  };
63 
87  ImageTransfer(OperationMode mode, const char* remoteAddress, const char* remoteService,
88  const char* localAddress, const char* localService, int bufferSize = 1048576,
89  int maxUdpPacketSize = 1472);
90 
91  ~ImageTransfer();
92 
99  void setRawTransferData(const ImagePair& metaData, unsigned char* rawData,
100  int secondTileWidth = 0, int validBytes = 0x7FFFFFFF);
101 
107  void setRawValidBytes(int validBytes);
108 
119  void setTransferImagePair(const ImagePair& imagePair);
120 
139  TransferStatus transferData(bool block);
140 
156  bool receiveImagePair(ImagePair& imagePair, bool block = true);
157 
167  bool receivePartialImagePair(ImagePair& imagePair, int& validRows, bool& complete, bool block = false);
168 
178  bool tryAccept();
179 
185  bool isClientConnected() const;
186 
193  void disconnect();
194 
202  std::string getClientAddress() const;
203 
204 private:
205  // We follow the pimpl idiom
206  class Pimpl;
207  Pimpl* pimpl;
208 
209  // This class cannot be copied
210  ImageTransfer(const ImageTransfer& other);
211  ImageTransfer& operator=(const ImageTransfer&);
212 };
213 
214 #endif
The connection has been closed by the remote host.
Definition: imagetransfer.h:48
Using TCP and acting as communication server.
Definition: imagetransfer.h:42
OperationMode
Supported transfer modes.
Definition: imagetransfer.h:33
Using TCP and acting as communication client.
Definition: imagetransfer.h:39
Class for synchronous transfer of image pairs.
Definition: imagetransfer.h:30
The image pair has been transferred completely.
Definition: imagetransfer.h:51
TransferStatus
The result of a partial image transfer.
Definition: imagetransfer.h:46
A set of two images, which are usually the left camera image and the disparity map.
Definition: imagepair.h:30
There is currently no more data that could be transmitted.
Definition: imagetransfer.h:58
Nerian Vision Technologies