58 | {
59 | public:
60 |
61 | /**
62 | * Constructor
63 | */
64 | BowVector(void);
65 |
66 | /**
67 | * Destructor
68 | */
69 | ~BowVector(void);
70 |
71 | /**
72 | * Adds a value to a word value existing in the vector, or creates a new
73 | * word with the given value
74 | * @param id word id to look for
75 | * @param v value to create the word with, or to add to existing word
76 | */
77 | void addWeight(WordId id, WordValue v);
78 |
79 | /**
80 | * Adds a word with a value to the vector only if this does not exist yet
81 | * @param id word id to look for
82 | * @param v value to give to the word if this does not exist
83 | */
84 | void addIfNotExist(WordId id, WordValue v);
85 |
86 | /**
87 | * L1-Normalizes the values in the vector
88 | * @param norm_type norm used
89 | */
90 | void normalize(LNorm norm_type);
91 |
92 | /**
93 | * Prints the content of the bow vector
94 | * @param out stream
95 | * @param v
96 | */
97 | friend std::ostream& operator<<(std::ostream &out, const BowVector &v);
98 |
99 | /**
100 | * Saves the bow vector as a vector in a matlab file
101 | * @param filename
102 | * @param W number of words in the vocabulary
103 | */
104 | void saveM(const std::string &filename, size_t W) const;
105 | };
106 |
107 | } // namespace DBoW2
108 |
109 | #endif
110 |
--------------------------------------------------------------------------------
/pose_graph/include/ThirdParty/DBoW/DBoW2.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: DBoW2.h
3 | * Date: November 2011
4 | * Author: Dorian Galvez-Lopez
5 | * Description: Generic include file for the DBoW2 classes and
6 | * the specialized vocabularies and databases
7 | * License: see the LICENSE.txt file
8 | *
9 | */
10 |
11 | /*! \mainpage DBoW2 Library
12 | *
13 | * DBoW2 library for C++:
14 | * Bag-of-word image database for image retrieval.
15 | *
16 | * Written by Dorian Galvez-Lopez,
17 | * University of Zaragoza
18 | *
19 | * Check my website to obtain updates: http://doriangalvez.com
20 | *
21 | * \section requirements Requirements
22 | * This library requires the DUtils, DUtilsCV, DVision and OpenCV libraries,
23 | * as well as the boost::dynamic_bitset class.
24 | *
25 | * \section citation Citation
26 | * If you use this software in academic works, please cite:
27 |
28 | @@ARTICLE{GalvezTRO12,
29 | author={Galvez-Lopez, Dorian and Tardos, J. D.},
30 | journal={IEEE Transactions on Robotics},
31 | title={Bags of Binary Words for Fast Place Recognition in Image Sequences},
32 | year={2012},
33 | month={October},
34 | volume={28},
35 | number={5},
36 | pages={1188--1197},
37 | doi={10.1109/TRO.2012.2197158},
38 | ISSN={1552-3098}
39 | }
40 |
41 | *
42 | * \section license License
43 | * This file is licensed under a Creative Commons
44 | * Attribution-NonCommercial-ShareAlike 3.0 license.
45 | * This file can be freely used and users can use, download and edit this file
46 | * provided that credit is attributed to the original author. No users are
47 | * permitted to use this file for commercial purposes unless explicit permission
48 | * is given by the original author. Derivative works must be licensed using the
49 | * same or similar license.
50 | * Check http://creativecommons.org/licenses/by-nc-sa/3.0/ to obtain further
51 | * details.
52 | *
53 | */
54 |
55 | #ifndef __D_T_DBOW2__
56 | #define __D_T_DBOW2__
57 |
58 | /// Includes all the data structures to manage vocabularies and image databases
59 | namespace DBoW2
60 | {
61 | }
62 |
63 | #include "TemplatedVocabulary.h"
64 | #include "TemplatedDatabase.h"
65 | #include "BowVector.h"
66 | #include "FeatureVector.h"
67 | #include "QueryResults.h"
68 | #include "FBrief.h"
69 |
70 | /// BRIEF Vocabulary
71 | typedef DBoW2::TemplatedVocabulary
72 | BriefVocabulary;
73 |
74 | /// BRIEF Database
75 | typedef DBoW2::TemplatedDatabase
76 | BriefDatabase;
77 |
78 | #endif
79 |
80 |
--------------------------------------------------------------------------------
/pose_graph/include/ThirdParty/DBoW/FBrief.h:
--------------------------------------------------------------------------------
1 | /**
2 | * File: FBrief.h
3 | * Date: November 2011
4 | * Author: Dorian Galvez-Lopez
5 | * Description: functions for BRIEF descriptors
6 | * License: see the LICENSE.txt file
7 | *
8 | */
9 |
10 | #ifndef __D_T_F_BRIEF__
11 | #define __D_T_F_BRIEF__
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | #include "FClass.h"
18 | #include "../DVision/DVision.h"
19 |
20 | namespace DBoW2 {
21 |
22 | /// Functions to manipulate BRIEF descriptors
23 | class FBrief: protected FClass
24 | {
25 | public:
26 |
27 | typedef DVision::BRIEF::bitset TDescriptor;
28 | typedef const TDescriptor *pDescriptor;
29 |
30 | /**
31 | * Calculates the mean value of a set of descriptors
32 | * @param descriptors
33 | * @param mean mean descriptor
34 | */
35 | static void meanValue(const std::vector &descriptors,
36 | TDescriptor &mean);
37 |
38 | /**
39 | * Calculates the distance between two descriptors
40 | * @param a
41 | * @param b
42 | * @return distance
43 | */
44 | static double distance(const TDescriptor &a, const TDescriptor &b);
45 |
46 | /**
47 | * Returns a string version of the descriptor
48 | * @param a descriptor
49 | * @return string version
50 | */
51 | static std::string toString(const TDescriptor &a);
52 |
53 | /**
54 | * Returns a descriptor from a string
55 | * @param a descriptor
56 | * @param s string version
57 | */
58 | static void fromString(TDescriptor &a, const std::string &s);
59 |
60 | /**
61 | * Returns a mat with the descriptors in float format
62 | * @param descriptors
63 | * @param mat (out) NxL 32F matrix
64 | */
65 | static void toMat32F(const std::vector &descriptors,
66 | cv::Mat &mat);
67 |
68 | };
69 |
70 | } // namespace DBoW2
71 |
72 | #endif
73 |
74 |
--------------------------------------------------------------------------------
/pose_graph/include/ThirdParty/DBoW/FClass.h:
--------------------------------------------------------------------------------
1 | /**
2 | * File: FClass.h
3 | * Date: November 2011
4 | * Author: Dorian Galvez-Lopez
5 | * Description: generic FClass to instantiate templated classes
6 | * License: see the LICENSE.txt file
7 | *
8 | */
9 |
10 | #ifndef __D_T_FCLASS__
11 | #define __D_T_FCLASS__
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | namespace DBoW2 {
18 |
19 | /// Generic class to encapsulate functions to manage descriptors.
20 | /**
21 | * This class must be inherited. Derived classes can be used as the
22 | * parameter F when creating Templated structures
23 | * (TemplatedVocabulary, TemplatedDatabase, ...)
24 | */
25 | class FClass
26 | {
27 | class TDescriptor;
28 | typedef const TDescriptor *pDescriptor;
29 |
30 | /**
31 | * Calculates the mean value of a set of descriptors
32 | * @param descriptors
33 | * @param mean mean descriptor
34 | */
35 | virtual void meanValue(const std::vector &descriptors,
36 | TDescriptor &mean) = 0;
37 |
38 | /**
39 | * Calculates the distance between two descriptors
40 | * @param a
41 | * @param b
42 | * @return distance
43 | */
44 | static double distance(const TDescriptor &a, const TDescriptor &b);
45 |
46 | /**
47 | * Returns a string version of the descriptor
48 | * @param a descriptor
49 | * @return string version
50 | */
51 | static std::string toString(const TDescriptor &a);
52 |
53 | /**
54 | * Returns a descriptor from a string
55 | * @param a descriptor
56 | * @param s string version
57 | */
58 | static void fromString(TDescriptor &a, const std::string &s);
59 |
60 | /**
61 | * Returns a mat with the descriptors in float format
62 | * @param descriptors
63 | * @param mat (out) NxL 32F matrix
64 | */
65 | static void toMat32F(const std::vector &descriptors,
66 | cv::Mat &mat);
67 | };
68 |
69 | } // namespace DBoW2
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/pose_graph/include/ThirdParty/DBoW/FeatureVector.h:
--------------------------------------------------------------------------------
1 | /**
2 | * File: FeatureVector.h
3 | * Date: November 2011
4 | * Author: Dorian Galvez-Lopez
5 | * Description: feature vector
6 | * License: see the LICENSE.txt file
7 | *
8 | */
9 |
10 | #ifndef __D_T_FEATURE_VECTOR__
11 | #define __D_T_FEATURE_VECTOR__
12 |
13 | #include "BowVector.h"
14 | #include