libvisiontransfer  6.5.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 
99  void setRawTransferData(const ImagePair& metaData, unsigned char* rawData,
100  int firstTileWidth = 0, int secondTileWidth = 0, int validBytes = 0x7FFFFFFF);
101 
111  void setRawValidBytes(int validBytes);
112 
121  const unsigned char* getTransferMessage(int& length);
122 
126  bool transferComplete();
127 
132  void resetTransfer();
133 
148  bool getReceivedImagePair(ImagePair& imagePair);
149 
172  bool getPartiallyReceivedImagePair(ImagePair& imagePair, int& validRows, bool& complete);
173 
177  bool imagesReceived() const;
178 
185  unsigned char* getNextReceiveBuffer(int& maxLength);
186 
202  void processReceivedMessage(int length);
203 
211  int getNumDroppedFrames() const;
212 
217  void resetReception();
218 
223  bool newClientConnected();
224 
228  bool isConnected() const;
229 
239  const unsigned char* getNextControlMessage(int& length);
240 
241 private:
242  // We follow the pimpl idiom
243  class Pimpl;
244  Pimpl* pimpl;
245 
246  // This class cannot be copied
247  ImageProtocol(const ImageProtocol& other);
248  ImageProtocol& operator=(const ImageProtocol&);
249 };
250 
251 } // namespace
252 
253 #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