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 <mutex>
25
27
28#include "KeypointManager.h"
29
30namespace armarx
31{
32 /**
33 * @class ImageKeypointBuffer
34 * @brief A brief description
35 *
36 * Detailed Description
37 */
39 {
40 public:
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
62 using ImageKeypointTriplePtr = std::shared_ptr<ImageKeypointTriple>;
63
64 /**
65 * ImageKeypointBuffer Constructor
66 */
67 ImageKeypointBuffer(const visionx::ImageProviderInfo& imageProviderInfo);
68
69 /**
70 * ImageKeypointBuffer Destructor
71 */
73
74 bool addRGBImage(CByteImage* rgbImage, long timestamp);
75 bool addDepthImage(CByteImage* depthImage, long timestamp);
76 bool addKeypoints(KeypointManagerPtr keypoints, long timestamp);
77
78 ImageKeypointTriplePtr getTripleAtTimestamp(long timestamp, bool deleteOlderTriples = true);
79 std::pair<long, ImageKeypointBuffer::ImageKeypointTriplePtr> getOldestTriple();
80 std::pair<long, ImageKeypointBuffer::ImageKeypointTriplePtr>
81 getOldestCompleteTriple(bool deleteOlderTriples = true);
82
83 void clear();
84
85 private:
86 std::mutex _bufferMutex;
87 std::map<long, ImageKeypointTriplePtr> _buffer;
88 visionx::ImageProviderInfo _imageProviderInfo;
89
90 ImageKeypointTriplePtr ensureTriple(long timestamp);
91 bool isComplete(long timestamp);
92 void deleteOlderEntries(
93 std::map<long, ImageKeypointBuffer::ImageKeypointTriplePtr>::iterator it);
94 };
95
96 typedef std::shared_ptr<ImageKeypointBuffer> ImageKeypointBufferPtr;
97} // namespace armarx
std::string timestamp()
ImageKeypointBuffer(const visionx::ImageProviderInfo &imageProviderInfo)
ImageKeypointBuffer Constructor.
bool addRGBImage(CByteImage *rgbImage, long timestamp)
bool addKeypoints(KeypointManagerPtr keypoints, long timestamp)
~ImageKeypointBuffer()
ImageKeypointBuffer Destructor.
std::pair< long, ImageKeypointBuffer::ImageKeypointTriplePtr > getOldestCompleteTriple(bool deleteOlderTriples=true)
bool addDepthImage(CByteImage *depthImage, long timestamp)
ImageKeypointTriplePtr getTripleAtTimestamp(long timestamp, bool deleteOlderTriples=true)
std::pair< long, ImageKeypointBuffer::ImageKeypointTriplePtr > getOldestTriple()
std::shared_ptr< ImageKeypointTriple > ImageKeypointTriplePtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< ImageKeypointBuffer > ImageKeypointBufferPtr
std::shared_ptr< KeypointManager > KeypointManagerPtr