NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
vocab_tree.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 /*
20  * Copyright 2011-2012 Noah Snavely, Cornell University
21  * (snavely@cs.cornell.edu). All rights reserved.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26 
27  * 1. Redistributions of source code must retain the above copyright
28  * notice, this list of conditions and the following disclaimer.
29  *
30  * 2. Redistributions in binary form must reproduce the above
31  * copyright notice, this list of conditions and the following
32  * disclaimer in the documentation and/or other materials provided
33  * with the distribution.
34  *
35  * THIS SOFTWARE IS PROVIDED BY NOAH SNAVELY ''AS IS'' AND ANY EXPRESS
36  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38  * ARE DISCLAIMED. IN NO EVENT SHALL NOAH SNAVELY OR CONTRIBUTORS BE
39  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
41  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
45  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
46  * DAMAGE.
47  *
48  * The views and conclusions contained in the software and
49  * documentation are those of the authors and should not be
50  * interpreted as representing official policies, either expressed or
51  * implied, of Cornell University.
52  *
53  */
54 
55 #ifndef SPARSE_MAPPING_VOCAB_TREE_H_
56 #define SPARSE_MAPPING_VOCAB_TREE_H_
57 
58 #include <google/protobuf/io/zero_copy_stream_impl.h>
59 
60 #include <vector>
61 #include <string>
62 #include <map>
63 
64 namespace cv {
65  class Mat;
66 }
67 
68 namespace sparse_mapping {
69  class SparseMap;
70  class BinaryDB;
71  class FloatDB;
72 
73  // A class for holding a vocab database of features.
74  struct VocabDB {
75  // There can be only one type of database now:
76  // - DBoW2 binary descriptors (e.g., BRISK, BRIEF)
77  // Only one of these is active at one time.
79 
81  VocabDB();
82  ~VocabDB();
83  void SaveProtobuf(google::protobuf::io::ZeroCopyOutputStream* output) const;
84  void LoadProtobuf(google::protobuf::io::ZeroCopyInputStream* input, int db_type);
85  };
86 
87  void DBSanityChecks(std::string const& db_type,
88  std::string const& descriptor);
89 
90  void BuildDB(std::string const& map_file,
91  std::string const& descriptor,
92  int depth, int branching_factor, int restarts);
93 
94  void ResetDB(VocabDB* db);
95 
96  // Query similar images from database
97  void QueryDB(std::string const& descriptor, VocabDB* vocab_db, int num_similar, cv::Mat const& descriptors,
98  std::vector<int>* indices, std::vector<double>* scores);
99 
101  std::string const& descriptor,
102  int depth, int branching_factor, int restarts);
103 } // namespace sparse_mapping
104 
105 #endif // SPARSE_MAPPING_VOCAB_TREE_H_
sparse_mapping::VocabDB::~VocabDB
~VocabDB()
Definition: vocab_tree.cc:290
sparse_mapping::BuildDB
void BuildDB(std::string const &map_file, std::string const &descriptor, int depth, int branching_factor, int restarts)
Definition: vocab_tree.cc:312
sparse_mapping::BuildDBforDBoW2
void BuildDBforDBoW2(sparse_mapping::SparseMap *map, std::string const &descriptor, int depth, int branching_factor, int restarts)
Definition: vocab_tree.cc:412
sparse_mapping::VocabDB::LoadProtobuf
void LoadProtobuf(google::protobuf::io::ZeroCopyInputStream *input, int db_type)
Definition: vocab_tree.cc:302
sparse_mapping::DBSanityChecks
void DBSanityChecks(std::string const &db_type, std::string const &descriptor)
sparse_mapping
Definition: localization_parameters.h:22
sparse_mapping::ResetDB
void ResetDB(VocabDB *db)
Definition: vocab_tree.cc:335
sparse_mapping::VocabDB::VocabDB
VocabDB()
Definition: vocab_tree.cc:287
sparse_mapping::VocabDB::SaveProtobuf
void SaveProtobuf(google::protobuf::io::ZeroCopyOutputStream *output) const
Definition: vocab_tree.cc:294
sparse_mapping::VocabDB::binary_db
BinaryDB * binary_db
Definition: vocab_tree.h:78
sparse_mapping::VocabDB
Definition: vocab_tree.h:74
sparse_mapping::QueryDB
void QueryDB(std::string const &descriptor, VocabDB *vocab_db, int num_similar, cv::Mat const &descriptors, std::vector< int > *indices, std::vector< double > *scores)
Definition: vocab_tree.cc:380
sparse_mapping::VocabDB::m_num_nodes
int m_num_nodes
Definition: vocab_tree.h:80
sparse_mapping::BinaryDB
Definition: vocab_tree.cc:105
cv
Definition: camera_params.h:31
sparse_mapping::SparseMap
Definition: sparse_map.h:63