RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
VisualWord.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Universite de Sherbrooke nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#pragma once
29
30#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
31
32#include <opencv2/core/core.hpp>
33#include <map>
34
35namespace rtabmap
36{
37
49class RTABMAP_CORE_EXPORT VisualWord
50{
51public:
58 VisualWord(int id, const cv::Mat & descriptor, int signatureId = 0);
59
64
69 void addRef(int signatureId);
70
76 int removeAllRef(int signatureId);
77
82 unsigned long getMemoryUsed() const;
83
88 int getTotalReferences() const {return _totalReferences;}
89
94 int id() const {return _id;}
95
100 const cv::Mat & getDescriptor() const {return _descriptor;}
101
106 const std::map<int, int> & getReferences() const {return _references;}
107
112 bool isSaved() const {return _saved;}
113
118 void setSaved(bool saved) {_saved = saved;}
119
120private:
121 int _id;
122 cv::Mat _descriptor;
123 bool _saved;
124
125 int _totalReferences;
126 std::map<int, int> _references;
127};
128
129} // namespace rtabmap
Represents a visual word (feature descriptor) used in the bag-of-words (BoW) model.
Definition VisualWord.h:50
const cv::Mat & getDescriptor() const
Returns the feature descriptor of this word.
Definition VisualWord.h:100
int getTotalReferences() const
Returns the total number of references (across all signatures).
Definition VisualWord.h:88
bool isSaved() const
Checks if the word has been saved to the database.
Definition VisualWord.h:112
void addRef(int signatureId)
Adds a reference to this word for the given signature ID.
void setSaved(bool saved)
Sets the saved flag for the word.
Definition VisualWord.h:118
int removeAllRef(int signatureId)
Removes all references to this word for the given signature ID.
VisualWord(int id, const cv::Mat &descriptor, int signatureId=0)
Constructor.
int id() const
Returns the ID of this visual word.
Definition VisualWord.h:94
unsigned long getMemoryUsed() const
Estimates the memory used by this visual word in bytes.
~VisualWord()
Destructor.
const std::map< int, int > & getReferences() const
Returns the references of this word.
Definition VisualWord.h:106