libvisiontransfer  10.6.0
imagetransfer.h
1 /*******************************************************************************
2  * Copyright (c) 2023 Allied Vision Technologies 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_IMAGETRANSFER_H
16 #define VISIONTRANSFER_IMAGETRANSFER_H
17 
18 #include <string>
19 #include "visiontransfer/common.h"
20 #include "visiontransfer/imageprotocol.h"
21 #include "visiontransfer/imageset.h"
22 #include "visiontransfer/deviceinfo.h"
23 
24 namespace visiontransfer {
25 
40 class VT_EXPORT ImageTransfer {
41 public:
43  enum TransferStatus {
45  ALL_TRANSFERRED,
46 
49  PARTIAL_TRANSFER,
50 
52  NO_VALID_DATA,
53 
55  WOULD_BLOCK,
56 
58  NOT_CONNECTED
59  };
60 
76  ImageTransfer(const char* address, const char* service = "7681",
78  bool server = false, int bufferSize = 16*1048576, int maxUdpPacketSize = 1472);
79 
89  ImageTransfer(const DeviceInfo& device, int bufferSize = 16 * 1048576,
90  int maxUdpPacketSize = 1472);
91 
92  ~ImageTransfer();
93 
100  void setRawTransferData(const ImageSet& metaData, const std::vector<unsigned char*>& rawData,
101  int firstTileWidth = 0, int middleTileWidth = 0, int lastTileWidth = 0);
102 
108  void setRawValidBytes(const std::vector<int>& validBytes);
109 
120  void setTransferImageSet(const ImageSet& imageSet);
121 
144  TransferStatus transferData();
145 
161  bool receiveImageSet(ImageSet& imageSet);
162 
163 #ifndef DOXYGEN_SHOULD_SKIP_THIS
164  DEPRECATED("Use receiveImageSet() instead")
165  inline bool receiveImagePair(ImageSet& imageSet) {
166  return receiveImageSet(imageSet);
167  }
168 #endif
169 
179  bool receivePartialImageSet(ImageSet& imageSet, int& validRows, bool& complete);
180 
181 #ifndef DOXYGEN_SHOULD_SKIP_THIS
182  DEPRECATED("Use receivePartialImageSet() instead")
183  inline bool receivePartialImagePair(ImageSet& imageSet, int& validRows, bool& complete) {
184  return receivePartialImageSet(imageSet, validRows, complete);
185  }
186 #endif
187 
195  int getNumDroppedFrames() const;
196 
206  bool tryAccept();
207 
211  bool isConnected() const;
212 
218  void disconnect();
219 
225  std::string getRemoteAddress() const;
226 
227 #ifndef DOXYGEN_SHOULD_SKIP_THIS
228  std::string statusReport();
230 #endif
231 
232 private:
233  // We follow the pimpl idiom
234  class Pimpl;
235  Pimpl* pimpl;
236 
237  // This class cannot be copied
238  ImageTransfer(const ImageTransfer& other);
239  ImageTransfer& operator=(const ImageTransfer&);
240 };
241 
242 } // namespace
243 
244 #endif
visiontransfer::ImageTransfer::TransferStatus
TransferStatus
The result of a partial image transfer.
Definition: imagetransfer.h:67
visiontransfer::ImageProtocol::PROTOCOL_UDP
@ PROTOCOL_UDP
The connection-less UDP transport protocol.
Definition: imageprotocol.h:84
visiontransfer::DeviceInfo
Aggregates information about a discovered device.
Definition: deviceinfo.h:59
visiontransfer::ImageSet
A set of one to three images, but usually two (the left camera image and the disparity map)....
Definition: imageset.h:50
visiontransfer::ImageProtocol::ProtocolType
ProtocolType
Supported network protocols.
Definition: imageprotocol.h:67
visiontransfer::ImageTransfer
Class for synchronous transfer of image sets.
Definition: imagetransfer.h:52
Allied Vision