ImageBuffer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 #include <mutex>
5 
6 
7 class CByteImage;
8 namespace visionx
9 {
10  class ImageProviderInfo;
11 }
12 
13 namespace visionx
14 {
15 
16  /**
17  * @brief Handler of image buffer for ImageProcessors.
18  *
19  * How to call allocate (in `onConnectImageProcessor()`):
20  *
21  * @code
22  * visionx::ImageProviderInfo imageProviderInfo = getImageProvider(providerName);
23  *
24  * imageBuffer.allocate(providerInfo);
25  * @endcode
26  *
27  *
28  * How to call update (in `process()`):
29  *
30  * @code
31  * int numReceived = 0;
32  *
33  * imageBuffer.update([this, &numReceived](CByteImage** images)
34  * {
35  * numReceived = getImages(images);
36  * });
37  * @endcode
38  */
40  {
41  public:
42 
43  ~ImageBuffer();
44 
45  void allocate(const visionx::ImageProviderInfo& providerInfo);
46 
47  void update(std::function<void(CByteImage**)> setImagesFn);
48 
49 
50  mutable std::mutex mutex;
51 
52  CByteImage** images = nullptr;
53  /// Update this each time you update images.
54  long imagesSeq = 0;
55 
56 
57  private:
58 
59  unsigned int numImages = 0;
60 
61  };
62 
63 }
visionx::ImageBuffer::images
CByteImage ** images
Definition: ImageBuffer.h:52
visionx::ImageBuffer::update
void update(std::function< void(CByteImage **)> setImagesFn)
Definition: ImageBuffer.cpp:37
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ImageBuffer::~ImageBuffer
~ImageBuffer()
Definition: ImageBuffer.cpp:12
visionx::ImageBuffer
Handler of image buffer for ImageProcessors.
Definition: ImageBuffer.h:39
visionx::ImageBuffer::mutex
std::mutex mutex
Definition: ImageBuffer.h:50
visionx::ImageProviderInfo
Definition: ImageProcessor.h:466
visionx::ImageBuffer::imagesSeq
long imagesSeq
Update this each time you update images.
Definition: ImageBuffer.h:54
visionx::ImageBuffer::allocate
void allocate(const visionx::ImageProviderInfo &providerInfo)
Definition: ImageBuffer.cpp:24