libvisiontransfer  6.4.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 
100  void setRawTransferData(const ImagePair& metaData, unsigned char* rawData,
101  int firstTileWidth = 0, int secondTileWidth = 0, int validBytes = 0x7FFFFFFF);
102 
112  void setRawValidBytes(int validBytes);
113 
122  const unsigned char* getTransferMessage(int& length);
123 
127  bool transferComplete();
128 
133  void resetTransfer();
134 
149  bool getReceivedImagePair(ImagePair& imagePair);
150 
173  bool getPartiallyReceivedImagePair(ImagePair& imagePair, int& validRows, bool& complete);
174 
178  bool imagesReceived() const;
179 
186  unsigned char* getNextReceiveBuffer(int& maxLength);
187 
203  void processReceivedMessage(int length);
204 
212  int getNumDroppedFrames() const;
213 
218  void resetReception();
219 
224  bool newClientConnected();
225 
229  bool isConnected() const;
230 
240  const unsigned char* getNextControlMessage(int& length);
241 
242 private:
243  // We follow the pimpl idiom
244  class Pimpl;
245  Pimpl* pimpl;
246 
247  // This class cannot be copied
248  ImageProtocol(const ImageProtocol& other);
249  ImageProtocol& operator=(const ImageProtocol&);
250 };
251 
252 } // namespace
253 
254 #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