ImageKeypointBuffer.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package <PACKAGE_NAME>::<CATEGORY>::ImageKeypointBuffer
17  * @author Stefan Reither ( stef dot reither at web dot de )
18  * @date 2018
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 #pragma once
23 
24 #include "KeypointManager.h"
26 
27 #include <mutex>
28 
29 namespace armarx
30 {
31  /**
32  * @class ImageKeypointBuffer
33  * @brief A brief description
34  *
35  * Detailed Description
36  */
38  {
39  public:
40 
42  {
44  {
45  rgbImage = nullptr;
46  depthImage = nullptr;
47  keypoints.reset();
48  }
49 
51  {
52  delete rgbImage;
53  delete depthImage;
54  keypoints.reset();
55  }
56 
57  CByteImage* rgbImage;
58  CByteImage* depthImage;
60  };
61  using ImageKeypointTriplePtr = std::shared_ptr<ImageKeypointTriple>;
62 
63  /**
64  * ImageKeypointBuffer Constructor
65  */
66  ImageKeypointBuffer(const visionx::ImageProviderInfo& imageProviderInfo);
67 
68  /**
69  * ImageKeypointBuffer Destructor
70  */
72 
73  bool addRGBImage(CByteImage* rgbImage, long timestamp);
74  bool addDepthImage(CByteImage* depthImage, long timestamp);
75  bool addKeypoints(KeypointManagerPtr keypoints, long timestamp);
76 
77  ImageKeypointTriplePtr getTripleAtTimestamp(long timestamp, bool deleteOlderTriples = true);
78  std::pair<long, ImageKeypointBuffer::ImageKeypointTriplePtr> getOldestTriple();
79  std::pair<long, ImageKeypointBuffer::ImageKeypointTriplePtr> getOldestCompleteTriple(bool deleteOlderTriples = true);
80 
81  void clear();
82 
83  private:
84  std::mutex _bufferMutex;
85  std::map<long, ImageKeypointTriplePtr> _buffer;
86  visionx::ImageProviderInfo _imageProviderInfo;
87 
88  ImageKeypointTriplePtr ensureTriple(long timestamp);
89  bool isComplete(long timestamp);
90  void deleteOlderEntries(std::map<long, ImageKeypointBuffer::ImageKeypointTriplePtr>::iterator it);
91  };
92  typedef std::shared_ptr<ImageKeypointBuffer> ImageKeypointBufferPtr;
93 }
armarx::ImageKeypointBuffer::getOldestCompleteTriple
std::pair< long, ImageKeypointBuffer::ImageKeypointTriplePtr > getOldestCompleteTriple(bool deleteOlderTriples=true)
Definition: ImageKeypointBuffer.cpp:102
armarx::ImageKeypointBuffer::ImageKeypointTriple::ImageKeypointTriple
ImageKeypointTriple()
Definition: ImageKeypointBuffer.h:43
armarx::ImageKeypointBuffer::ImageKeypointTriple::depthImage
CByteImage * depthImage
Definition: ImageKeypointBuffer.h:58
armarx::ImageKeypointBuffer::addDepthImage
bool addDepthImage(CByteImage *depthImage, long timestamp)
Definition: ImageKeypointBuffer.cpp:48
armarx::ImageKeypointBuffer::ImageKeypointTriple::~ImageKeypointTriple
~ImageKeypointTriple()
Definition: ImageKeypointBuffer.h:50
armarx::ImageKeypointBuffer::addKeypoints
bool addKeypoints(KeypointManagerPtr keypoints, long timestamp)
Definition: ImageKeypointBuffer.cpp:58
armarx::KeypointManagerPtr
std::shared_ptr< KeypointManager > KeypointManagerPtr
Definition: KeypointManager.h:159
armarx::ImageKeypointBuffer::getTripleAtTimestamp
ImageKeypointTriplePtr getTripleAtTimestamp(long timestamp, bool deleteOlderTriples=true)
Definition: ImageKeypointBuffer.cpp:67
armarx::ImageKeypointBuffer::ImageKeypointBuffer
ImageKeypointBuffer(const visionx::ImageProviderInfo &imageProviderInfo)
ImageKeypointBuffer Constructor.
Definition: ImageKeypointBuffer.cpp:28
armarx::ImageKeypointBufferPtr
std::shared_ptr< ImageKeypointBuffer > ImageKeypointBufferPtr
Definition: ImageKeypointBuffer.h:92
armarx::ImageKeypointBuffer::ImageKeypointTriple
Definition: ImageKeypointBuffer.h:41
armarx::ImageKeypointBuffer::getOldestTriple
std::pair< long, ImageKeypointBuffer::ImageKeypointTriplePtr > getOldestTriple()
Definition: ImageKeypointBuffer.cpp:87
armarx::ImageKeypointBuffer::ImageKeypointTriple::rgbImage
CByteImage * rgbImage
Definition: ImageKeypointBuffer.h:57
armarx::ImageKeypointBuffer::clear
void clear()
Definition: ImageKeypointBuffer.cpp:120
visionx::ImageProviderInfo
Definition: ImageProcessor.h:466
ImageProcessor.h
armarx::ImageKeypointBuffer::~ImageKeypointBuffer
~ImageKeypointBuffer()
ImageKeypointBuffer Destructor.
Definition: ImageKeypointBuffer.cpp:33
armarx::ImageKeypointBuffer
A brief description.
Definition: ImageKeypointBuffer.h:37
armarx::ImageKeypointBuffer::ImageKeypointTriplePtr
std::shared_ptr< ImageKeypointTriple > ImageKeypointTriplePtr
Definition: ImageKeypointBuffer.h:61
KeypointManager.h
armarx::ImageKeypointBuffer::addRGBImage
bool addRGBImage(CByteImage *rgbImage, long timestamp)
Definition: ImageKeypointBuffer.cpp:38
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::ImageKeypointBuffer::ImageKeypointTriple::keypoints
KeypointManagerPtr keypoints
Definition: ImageKeypointBuffer.h:59