libvisiontransfer  7.1.0
imageprotocol.h
1 /*******************************************************************************
2  * Copyright (c) 2019 Nerian Vision GmbH
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_IMAGEPROTOCOL_H
16 #define VISIONTRANSFER_IMAGEPROTOCOL_H
17 
18 #include "visiontransfer/common.h"
19 #include "visiontransfer/imagepair.h"
20 
21 namespace visiontransfer {
22 
38 class VT_EXPORT ImageProtocol {
39 public:
41  enum ProtocolType {
44 
46  PROTOCOL_UDP
47  };
48 
56  ImageProtocol(bool server, ProtocolType protType, int maxUdpPacketSize = 1472);
57 
58  ~ImageProtocol();
59 
69  void setTransferImagePair(const ImagePair& imagePair);
70 
101  void setRawTransferData(const ImagePair& metaData, unsigned char* rawData,
102  int firstTileWidth = 0, int middleTilesWidth = 0, int lastTileWidth = 0, int validBytes = 0x7FFFFFFF);
103 
113  void setRawValidBytes(int validBytes);
114 
123  const unsigned char* getTransferMessage(int& length);
124 
128  bool transferComplete();
129 
134  void resetTransfer();
135 
150  bool getReceivedImagePair(ImagePair& imagePair);
151 
174  bool getPartiallyReceivedImagePair(ImagePair& imagePair, int& validRows, bool& complete);
175 
179  bool imagesReceived() const;
180 
187  unsigned char* getNextReceiveBuffer(int& maxLength);
188 
204  void processReceivedMessage(int length);
205 
213  int getNumDroppedFrames() const;
214 
219  void resetReception();
220 
225  bool newClientConnected();
226 
230  bool isConnected() const;
231 
241  const unsigned char* getNextControlMessage(int& length);
242 
243 private:
244  // We follow the pimpl idiom
245  class Pimpl;
246  Pimpl* pimpl;
247 
248  // This class cannot be copied
249  ImageProtocol(const ImageProtocol& other);
250  ImageProtocol& operator=(const ImageProtocol&);
251 };
252 
253 } // namespace
254 
255 #endif
A lightweight protocol for transferring image pairs.
Definition: imageprotocol.h:38
ProtocolType
Supported network protocols.
Definition: imageprotocol.h:41
The connection oriented TCP transport protocol.
Definition: imageprotocol.h:43
A set of two images, which are usually the left camera image and the disparity map.
Definition: imagepair.h:33
Nerian Vision Technologies